esp8266_12s

I wrote a sketch from \ resource \ Esp8266_01 at Esp8266_12. I received a response to the request http: //esp8266-01.local/ with a map of connected devices.

 I ran the script:

esp = Runtime.start ("esp", "Esp8266_01")

ada = Runtime.start ("Ada", "Adafruit16CServoDriver")

ada.attach (esp, "1", "0x40")

motor1 = runtime.start ("motor1", "MotorDualPwm")

motor1.setPwmPins (0,1)

motor1.attach (ada)

But, I do not get any engine action. The question is how to verify that data from the MRL is coming to ESP?

I, as I understand it, that there should be a chain: MRL-​​router-ESP-Adafruit16CServoDriver-engines.
Mats's picture

MRL needs to know the ip-address of the ESP8266

Hi

Your .understanding is correct. What's missing is that MRL need to know the ip-address of the ESP8266.

The default address set in MRL is 192.168.1.99

So after you start the ESP8266_01 service you need to set the host like this:

esp.setHost("192.168.1.100")

I hope it helps. If not then let me know. I have tested all the involved services before, but not in the combination you are trying now.

 

alexstarter's picture

  Thanks, Mats. I made

 
Thanks, Mats. I made changes and received a response in the port monitor from ESP. But the controller does not respond to PCA9685. Although I get a response that the device is connected to I2C. I spread the screen of the screen.
alexstarter's picture

  For Servo - it

 

For Servo - it works!
 
adaFruit16c = Runtime.start("AdaFruit16C","Adafruit16CServoDriver")
esp = Runtime.start("esp","Esp8266_01")
esp.setHost ("192.168.1.100")
adaFruit16c.attach("esp","0","0x40")
thumb = Runtime.start("Thumb", "Servo")
thumb.attach(adaFruit16c,3)
 
But for MotorDualPwm - no.
adaFruit16c = Runtime.start("AdaFruit16C","Adafruit16CServoDriver")
esp = Runtime.start("esp","Esp8266_01")
esp.setHost ("192.168.1.100")
adaFruit16c.attach("esp","0","0x40")
motor1 = runtime.start("motor1","MotorDualPwm")
motor1.setPwmPins(1,2)
motor1.attach(adaFruit16c)
 
 
It seems to me that the sketch in ESP does not correctly form PWM

 

Mats's picture

PWM

That it works for a servo is good news. To be honest, I never tried to run a servo on an ESP8266. So the fact that a servo works on an ESP8266_01 ( or 12 ) is good news. I think that writing i2c commands work. The Adfruit16CServoDriver ( PCA9685 ) only uses two commands.

One is to set the PWM frequency. For a servo it's default is 50 Hz ( 20 ms ). For a motor you may want a higher PWM frequency, The PWM frequency is set for the whole PCA9685 device, so don't mix motors and servos on the same device. This seems to work, since Servo works. It may be that the MotorDualPwm doesn't set the correct frequency .I need to check this.

The second command is to set the PWM proportions. For a servo, it changes so that the pulse length varies between 1 and 2 ms. This also seems to work, since Servo works.

For MororDualPwm you also have 2 more states. 100% on or 100% off. 100% off being one direction, 100% being the opposite direction. This might be where the problem is. 

What motor driver are you using ?  L298, IBT-2, IBT-4 or something else ?

Are you using MRL 1.0.2693 or "latest" ?

/Mats

alexstarter's picture

  I use four IBT-2 drivers

 
I use four IBT-2 drivers with a three-wire wiring diagram, MRL 1.0.2693. If I write:
 
port="COM4"
arduino = runtime.start("arduino","Arduino")
motor1 = runtime.start("motor1","MotorDualPwm")
motor2 = runtime.start("motor2","MotorDualPwm")
motor3 = runtime.start("motor3","MotorDualPwm")
motor4 = runtime.start("motor4","MotorDualPwm")
pin1 = Runtime.start('pin1','Relay')
pin2 = Runtime.start('pin2','Relay')
pin3 = Runtime.start('pin3','Relay')
pin4 = Runtime.start('pin4','Relay')
arduino.connect(port)
motor1.setPwmPins(2,3)
motor2.setPwmPins(4,5)
motor3.setPwmPins(6,7)
motor4.setPwmPins(8,9)
motor1.attach(arduino)
motor2.attach(arduino)
motor3.attach(arduino)
motor4.attach(arduino)
pin1.arduino = arduino
pin2.arduino = arduino
pin3.arduino = arduino
pin4.arduino = arduino
pin1.pin = 22
pin2.pin = 24
pin3.pin = 26
pin4.pin = 28
pin1.off()
pin2.off()
pin3.off()
pin4.off()
 
then wheel control works using MEGA 2560 via USB. Each drive is continuously adjustable. I can assume that the service from MRL is working correctly.
What "last" MRL are you talking about?
Mats's picture

Adafruit16CServoDriver

I made some test and found that the logic for the Adafruit16CServoDriver had been changed since my test in 2016. The pwm signal sent for the motor is just a 1/255 of what it should be, so the motor will not move. I have made changes and made a pull request for the change in the latest release. I hope one of the other developers will approve it.

To download the lastes release ( that is changing often ), you can find the link at the top of this page, in the Choutbox window. Just use the "latest" link. But please be aware that it may contain other changes that may be incompatible with the inmoov scritps ( or your own scripts ).

When I tested on the ESP8266 I found that it takes a lot of time for the commands to be sent across WiFi and then be converted to i2c commands. So I'm working on upgrading the communication to websockets. I have made some progress, so websockets are working on the ESP8266. Next step is to find out how to get MRL make use of it in the communication with the ESP8266.

 

alexstarter's picture

  Thanks, Mats. It's

 

Thanks, Mats. It's great that you took the time to help me. But I can’t find the Choutbox window on the page to download the latest release.
 

 

Mats's picture

Link to latest

http://build.myrobotlab.org:8080/job/myrobotlab-multibranch/job/develop/lastSuccessfulBuild/artifact/target/myrobotlab.jar

 

Create a new empty folder and put myrobotlab.jar there.