Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

Get Started
Resolved Resolved by ptp!

Sendserial Doesn't Work Correctly

I'm doing some experimentation sending  a serial message ( 115200 baud rate) to ezbv4. The project sends  a packet of 10 bytes every 100 mS. 
The packet is not always being sent every 100 mS, but  very often it is not sent, as you can see in this oscillogram.
 (each pulse you see is the 10 byte packet) . The're correctly spaced by 100 mS , but many are missing.
User-inserted image

Can somebody explain what's going on ??

Related Hardware EZ-B v4


Upgrade to ARC Pro

ARC Early Access will give you immediate updates and new features needed to unleash your robot's potential!

Please share the script, how many you sent ? The pic shows 11.
#2   — Edited
The script  was like this (send for ever) : 
sendserial(d0,115200,0x KK, .......)
sendserial (d0,115200,0xYY.......)
goto (a)

the scope shows only a few seconds
#4   — Edited


sendserial(d0,115200,0x KK, .......)
sendserial (d0,115200,0xYY.......)
goto (a)

Is this your exact script? The second sendserial command has a space between sendserial and the open parentheses....
#5   — Edited
That’s not code that would work. I also can’t correct the code because there’s not enough to understand. Please post the code you’re using. 

get a logic analyzer or use an arduino to better understand what transmitting you’re sending, and what’s not transmitting. Mainly cause ezscript doesn’t handle binary data in strings very well. So that’s why the hardware uart or JavaScript version of sendserial should be used. Ezscript is really only included in ARC for backward compatibility 

found this arduino logic analyzer if you have one lying around: https://create.arduino.cc/projecthub/vincenzo-g/diy-logic-analyzer-f61ee5

also, the software sendserial is a bit bang. Some client serial devices may require higher timing accuracy. In that case, use the hardware uart on the ezb v4

lastly, because you’re sending binary data, the hardware uart commands are best. If you wish to continue using sendserial, then use JavaScript because it will send binary data better. Ezscript isn’t great for that stuff...
Sorry,guys, i was outside, and now i see  many posts.  i'm replying to all. I had the script in another PC, so i wrote it .
here is the actual  code:

@PTP . The script should send  short pulses , each lasting about 800 uS ( 10 bytes at 155200 bauds ) .
This should happen every 100 mS, but the scope shows that many of them are skipped.
You also refer to a post of mine in 2016 when i, a newbie of ezb,  tried to use ezb's analog ports to make a feedback system, that couldn't work, because of the delay caused by ezb itself. You and others explained that ezb isn't a real time system. So, for that purpose i used a local  PIC MCU .
@DJ. sorry, Dj. I couldn't send the code before. it's up here.
I'haven't arduino or a logic analyzer. But my 100 Mhz Tektronix digital sampling oscilloscope shows with no doubt that many pulses are missing.
Note that the  software uart at pin D0 outputs a perfect sequence of 10 bytes  corresponding exactly to the script , but simply they aren't always sent every  100 mS as required by the script.
#7   — Edited
You can't expect 10 bytes each 100 ms !

What I wrote in 2016 is still true today. Please read again, the thread and the multiple posts, and let me know why you think this problem is not related.
#8   — Edited


Note that the software uart at pin D0 outputs a perfect sequence of 10 bytes corresponding exactly to the script , but simply they aren't always sent every 100 mS as required by the script.
I have read previous posts. Here the problem is different.
The 10 bytes sent at pin D0, at 115200 bauds, are perfect. The problem is the repetition every 100 mS. I could accept some error such as 70 or 130 mS  or more, instead of 100 mS,, but it often doesn't send anything  !...   why ?
#9   — Edited
Please try this script (verbatim)


repeat($x, 1, 16, 1)
SendSerial(D0, 115200, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
Please count the number of the packages and time between them

After try this one (verbatim):


repeat($x, 1, 16, 1)
SendSerial(D0, 115200, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
Please count the number of packages and time between them

Please post your findings
#11   — Edited
@DJ: I know.
I don't want to introduce another "variable" (i.e. javascript vs EZ-Script speed) to the reported problem.
In 2016 I've explained the issue, Leonardo is still not understanding the issue, so I'm doing baby steps.
#12   — Edited
@Lenny.... Try what ptp suggests in post #9... If script #1 works with a sleep(2000) but script #2 does not work (dropping packets) with a sleep(100) then you have your answer... If it were me I would try using the "hardware" uart instead of "software" sendserial... If that didn't work either I then would learn JavaScript... FYI based on this thread alone I will be personally taking the time to learn JavaScript....
Hi guys.
Test asked by PTP done.
Even sending the packets every  2000 mS, many packets are not sent !... Packets themselves are correct, , but   they don't repeat well, some are skipped, no matter what is the repetion rate (2000,1000,500,100, etc.) . If someone had an oscilloscope , he might see with his eyes what happens. 

I think it depends on the long time required by the ezb script to execute the  repetition.  For this now java is recommended by DJ.
DJ says  "ezb isn't good for this stuff".  java script should be better.
#14   — Edited
You wrote:


many packets are not sent
I only asked 2 simple questions
1) how many packets, did you get 16 packets ? Yes / NO
2) The timings between the packets ?
#15   — Edited
Sorry to insist but I mentioned the problem in 2016, and you didn't see the connection.
So before adding more variables Uart vs SoftwareSerial, or EZ-Script vs Javascript, I want you to understand the problem without missing steps (Wrong conclusion / Facts)
#16   — Edited
Sorry to PTP and others. 
I couldn't see the pulses . They are too narrow to be detectable in a  time  interval of 2x16 =32 seconds ! I only saw some ones.
So I used, for the 2000 mS script , simply a LED, and  no pulse was lost. Timing between pulses and inside the packets was correct.
For the 100 mS script  i used the oscilloscope, and 8-9 pulses were always lost, in a random way, as i had seen in previous tests.
The spacing between them was variable in a random way, around 100 mS, and,  inside the bytes,  timing was random as well.
My question is solved . Thanks everybody.  PTP solved.
What are you doing with the sendserial? Are you trying to communicate with another device? If so, is there anything we can do to help?

if you want to provide details of the thing you’re trying to do, that would be easiest for us to help
I'm still experimenting to  control ubtech alpha 1S servos with iotiny and ezbv4
i know your opinion about that (not enough info about  protocol ,etc.). A hopeless work. However i'm going on.
I saw that your plug-in sends  all together,  many ( 16x10-byte) messages, for  16 servos. Perhaps  too many.
I'm trying to send single messages, for a single servo, to see what happens.
I need some tool to send perfect messages, and realized that sendserial isn't good for that. 
What was used in your plug-in?  what can I use ?