Help with Receiving serial data
Siri
Posts: 220
I am working with a stepper motor/driver "Little Step-U" from parallax shop.
I am able to send commands to the stepper and they work well - using spin object - "Full Duplex Serial" and other serial objects.
I am unable to receive any serial data from the Stepper driver.
When the command "{V}" is sent - the state of the two "Stops" are sent back in this ·format.
··························· " [noparse][[/noparse]a,b]" - "a" ·and "b" are binary "0" or"1" - open or closed.
I have tried using BS2 Functions - which is the only way I seem to have found that has a serial command
to "WAIT for CHAR" - "[noparse][[/noparse]" - · function but I cannot get it to work.
Is there a way I can do this using the serial spin objects without cog lock-up.
Thank you.
Siri
P.S - Attached is the Stepper motor specs.
I am able to send commands to the stepper and they work well - using spin object - "Full Duplex Serial" and other serial objects.
I am unable to receive any serial data from the Stepper driver.
When the command "{V}" is sent - the state of the two "Stops" are sent back in this ·format.
··························· " [noparse][[/noparse]a,b]" - "a" ·and "b" are binary "0" or"1" - open or closed.
I have tried using BS2 Functions - which is the only way I seem to have found that has a serial command
to "WAIT for CHAR" - "[noparse][[/noparse]" - · function but I cannot get it to work.
Is there a way I can do this using the serial spin objects without cog lock-up.
Thank you.
Siri
P.S - Attached is the Stepper motor specs.
Comments
I tried using Rxcheck as you suggested but was not sucessful.
When I run this code without the repeat in the "StepInit" method - the DebugGo method works and I receive "0 0 ".Even if I turn the motor to
the "Stop markers" - I still receive only "0" 's·· and no "1" 's.
If I run the the code with the "repeat" - the motor goes back and forth trggering the "stop markers" - but Debug part stops functioning and I do not receive any data - at least I can't see on the Debug screen.
I am execcuting the Debug code on a sepatate COG.
Thanks for the help
Siri
(unable to attach doc. - server failure) so here it is :
Code : CON
········· VAR
··············· long DebugStack[noparse][[/noparse]20]
········· OBj
··············· stepper:"Extendd Serial"
··············· Debug: "FullDuplexSerial"
········· PUB Main
················ Stepper.start(5,6,1,2400)··
stepper baud rate etc.
················ Debug.start(31,30,0,57600)
················ StepInit
················ cognew(DebugG0,@DebugStack)
········ PUB StepInit·························· 'stepper motor to go back and forth to stops A & B - "on and off"
·············· Repeat
······················ stepper.str(string("{K}"))·········· 'go clockwise to stop "A"
······················ waitcnt(clkfreq + cnt)
······················ stepper.str(string("{J}"))··········· 'go counter clockwise· to stop "B"
······················ waitcnt(clkfreq + cnt)
······ PUB DebugGo | a,b
·············
·········· Repeat
·············· waitcnt(clkfreq + cnt)
·············· stepper.str(string("{V}"))·············· 'request the positons of stops "A &B" - on/off --> 1 or 0
·············· If stepper.rxcheck == "[noparse][[/noparse]"··············· 'receiving format " [noparse][[/noparse]a,b]"
·················· a:= stepper.RxDec····················· 'receive "a" -->1 or 0
·················· b:= stepper.RxDec····················· 'receive " b" --> 1 or 0
·················· Debug.str(string(13)
···················Debug.Bin(a,1)
·················· Debug.str(string(13)
·················· Debug.Bin(b,1)
Post Edited (Siri) : 7/23/2008 1:30:26 AM GMT
Post Edited (Mike Green) : 7/23/2008 1:32:47 AM GMT
Thanks for the help.
I thought since they are two different objects that I could use them at the same time.
How do I use locks - I have never used them - giude me along.
Thanks
siri
I tried using " If ser.Rxcheck == "]" and when I try to capture the data after the "[noparse][[/noparse]" - I am unable to do so.
using· " a :=·ser.Rx " as shown in my prior post.
Then I tried using· : If ser.Rxcheck == "[noparse][[/noparse]"
······························ a:= ser.Rx(time)· --- using tme as 100 msec.
now I receive 4 bits of garbage but no "0" or "1".
Then I thought the stepper driver may be not working well.- but after using a BS2px set up·with DEBUG i- recived
"0" and "1". - so the stepper driver is working well.
I also tried changing the baud rate,mode inverted/non-inverted with all possible combinations - but yet I am
unable to receive the right out-put from the stepper drive.
I am using only one "serial object" - no duplicates and· PINS (5,6) to communicate with the stepper driver and PINS 30,31 for the DEBUG.
I appreciate any help I can get.
Siri
If there's a "[noparse][[/noparse]", then it accepts a single digit "0" or "1", then
a comma, then a single digit "0" or "1", then a "]".
Siri
I tried the code you suggested but I am still unable to receive any data back from the stepper driver.
I attached the code I used and BS2 code that works.
Hopefully this will help you figure out - if I am doing something wrong.
Thank you again.
P.S - How do one post code snippets like you did in the previous post.
Start a code block with "[noparse][[/noparse] code ]" without the spaces and end the code block with "[noparse][[/noparse] /code ]" also without the spaces. Not everything is left unaltered, but spacing is preserved.
Thanks for all the help.
I finally figured what the source of the problem.
When all spin code did not work - I suspected there must be a hardware problem.I connected the Stepper motor driver to BS2 setup and it worked flawlessly.Then I hooked up the scope to the stepper driver serial out-put and I was receivng a good signal - this confirmed that all is working well.
Then I placed the stepper motor driver in the Prop setup.I was able to run the motor in both directions using the commands with Full_Duplex_Serial.But for some reason there is no serial out-put was detected with the scope.I have double-trpple checked my wiring and all the connections,I am not using that particular PIN for any other task.
The question now is why I can communicate only in one direction with the stepper motor driver.
I tried changing the I/O pin direction form input/ouput - high and low still I am unable to record any out-put from the Stepper motor driver.
The stepper motor Driver is driven by 5V DC and I have connected the 3 pins to the prop via 2K ohm resisitors
and it reads 3.1V for all the 3 pins at the prop.- but still no out-put from the serial out from the Stepper driver.
I can do directly back to the BS2 setup and the same serial out pin from the steppr driver and the GND will record a normal serial signal on the scope.
Why is the Prop and the Stepper driver "NOT work together.
Siri
Post Edited (Siri) : 7/28/2008 7:57:39 PM GMT