Most recent activity
-
- 9 comments
- 3,259 views
-
Hi again guys, sorry for the late reply, I've been pretty busy last week, so I didn't have time to reply.
I tried Gordon's build, which worked for me. I've moved to pins A9 and A10 now. Communication is stable with this build.
Then I tried Drazzy's bigram build, version "espruino_1v72_12-17_espruino_1r3_bigram", which also worked, but only after I changed the timings a bit.
So instead of reading the buffer after 50ms, I had to do it after 150ms, or else it seemed the buffer wasn't "ready" yet (I would get random characters or only part of the reply string).
The program is stable with this timing, so my problem is solved, but maybe you guys know what could have caused the timing difference. Just letting you know :)
Thanks for the help and suggestions!
-
-
Hi all,
I'm working on a project involving communication via RS485. I use a MAX485 board to convert it all and it works fine up to a certain point.
A while ago, I installed one of @DrAzzy 's builds to get more RAM, since we needed that in the project. The thing is, since the new firmware install, the serial communication seems to have stopped working.
The code below works on the newest 'normal' firmware, but somehow the value of reply is still 0 when we run the code on one of Drazzy's builds.
digitalWrite(B8, 0); Serial1.setup(9600, {tx:B6,rx:B7,bytesize:8,parity:'none',stopbits:1}); var reply = 0; function sSend(command){ reply = 0; print("Command: "+command); digitalWrite(B8, 1); setTimeout(function(){Serial1.print(command);}, 5); setTimeout(function(){digitalWrite(B8, 0);}, command.length/0.96+6.53); setTimeout(function(){ reply = Serial1.read(); print("Reply: "+reply); if(reply === ""){ setTimeout(function(){sSend(command);},1000); } }, 50); }
sSend("@01EO=1\r") is the command we send to turn on the power for one of our connected devices and it should return "#01OK". If there is no reply (when the supply power is turned off for example), Serial1.read() should return "".
However, I noticed that when I run the code under Drazzy's firmware, Serial1.read() indeed returns "", but the actual value of reply is still 0, so sSend isn't called for a second time. It seems as if the code just stops there.I have a feeling it either has to do something with timing (although I tried a lot of different timings supported by my oscilloscope), or with the firmware not working well with Serial1.
Any thoughts and advices are welcome :)
-
- 3 comments
- 2,362 views
-
-
Hello,
I'm working on a project involving driving stepper motors via RS485.
I've found a nice converter board:http://arduino-info.wikispaces.com/SoftwareSerialRS485Example
I converted this example to JavaScript and I got it working.
digitalWrite(B8, 0); Serial1.setup(9600, {tx:B6,rx:B7,bytesize:8,parity:'none',stopbits:1}); Serial1.on('data', function (data) { print("<Serial1> "+data); }); digitalWrite(B8, 1); digitalWrite(LED2, 1); setTimeout(function() {Serial1.print("@01STOP\r");}, 5); setTimeout(function() {digitalWrite(B8, 0);}, 15);
The only problem is that the stepper motors have encoders, which will reply (very fast) when I send a serial command. This means I have to make my driver enable output LOW as fast as possible after sending my command.
Timeouts may work, but the timings vary, as different commands require more or less time to print.
Does anyone have any idea how to make sure the driver enable pin goes to LOW as soon as the Espruino is done sending?Sorry if my English is not that good, but I hope you guys can understand my question :)
Thanks in advance,
Eric
Yeah, that's the case then. If the serial buffer misses 1 bit of data, the whole string is shifted, so you get random characters.
The difference between 50 and 150ms is pretty big to be a minor change though, but it's no big deal to implement.
Thanks again :)