Prop to Prop communications with Simple serial library object
sjanicki
Posts: 3
I am fairly new to propeller programing so excuse me if these questions seem simple.
I wrote a program that utilizes the simple serial library object for communicating between two propellers. I can transmit a single byte but am having a difficult time getting multiple different bytes sent. I am sort of at a loss as where to start with sending more then one value serially.
My project is a tethered underwater ROV and I am trying to communicate a large number of different values down to the machine from the surface for motor control, lights, etc. If someone has an object that they think would work well for this then that would work great as well!
Any help would be greatly appreciated.
I wrote a program that utilizes the simple serial library object for communicating between two propellers. I can transmit a single byte but am having a difficult time getting multiple different bytes sent. I am sort of at a loss as where to start with sending more then one value serially.
My project is a tethered underwater ROV and I am trying to communicate a large number of different values down to the machine from the surface for motor control, lights, etc. If someone has an object that they think would work well for this then that would work great as well!
Any help would be greatly appreciated.
Comments
If you want more specific advice, you're going to have to be more specific in your questions. What do you want to send? What have you been able to do so far? What is or isn't working for you and what happens with the failures? What equipment do you have on the surface. I assume you have a Prop in the ROV, but how is it connected and what else is it doing? Details are important.
What I want to do: The prop onboard the ROV will be mounted on a PCB that has 8 h-bridge controllers for brushed motor control, a stepper motor amplifier, 4 DAC channels using PWM and a low pass filter. I have prototyped the motor controllers on a bread board and work fairly well. Same with the stepper motor and DAC. No value that I need to transmit is larger than a byte. The prop on the surface is also on a PCB with multiple switches and pushbuttons. It also has input from the MCP-3208 ADC for speed control of the motors from an analog joystick. Both PCBs have not yet been built and therefore can be changed as much as needed to get this to work.
What I have gotten to work so far: I have transmitted single bytes fairly easily but run into issues when I try to send more then that.
What I have tried: I have tried sending a known value to let the second prop know when to start storing the values, I then sent the values one at a time. I then tried to display said values on the Parallax serial terminal with results being either blank screen or garbled numbers.
Thanks so much for your help.
Basically bytes are put into an array when pst.RxCheck sees that there is data waiting
if the byte ends up being a "13" which is the decimal value of a carriage return, it considers that the "terminating byte" and it then sends the string through my parsing objects.
Delimiter finder will look for a specific delimiter (for me it was the = sign) so if I said speed=10, it would find the = sign and then parse the prefix and suffix. Variableupdator would then set the global variable of speed to a value of 10.
If you follow the logic, the code should make general sense. I'm not sure how to apply it to your application and your code.
1.) check for serial bytes, add them to a character array
2.) check for carriage return
3.) after carriage return is found, entire string is now available
4.) parse through string looking for delimiter, and therefore prefix and suffix
5.) set the prefix to the value of suffix (has to be global variables)
Continue
If you have problems, report back and I'll try and get it working for you. I remember this took me a long time to figure out and develop when I was in your shoes and had it not been for the patience of a couple of forum members (Duane Degn was one of them IIRC) I would have never gotten this to work.
Thanks again!
Can someone advise me why ???
repeat x from 0 to strsize(@outp1)
tx(byte[@outp1][x])
The above works where outp1 is BYTE in DAT.
BUT below is NOT ???
strAddr := @outp1
repeat x from 0 to strsize(strAddr)
tx(byte[strAddr][x])
It needs to be a word or long sized variable.
PUB str(strAddr)
if txOkay
repeat strsize(strAddr)
tx(byte[strAddr++])
BUT when I send in str(@outp1), it is not working. I am not sure what strAddr is declared as ?
Since passing @outp1 not working I have to try other ways....
BTW, at DAT, outp1 Byte "Get Data 1",0[10]
I know there must be something wrong somewhere but just can't figure out
If you're program is short you can post it with code blocks. Here's a link to a tutorial on how to use code blocks.
You can attach you code as an archive by compiling your program, then choosing File\Archive\Project...
You also need to keep in mind that simple serial can only use baud settings of 9600 or less.
I had a problem using simple serial in one of my projects. I never did figure out what the problem was. I decided it was easier to just use one of the other serial drivers since I had a cog I could spare.
Have you tried using the other serial objects?