Help needed with BS2/ Pololu qik2s9v.
DonN
Posts: 11
Good Morning all.
I have been working with a BS2 and a qik2s9v controller. I would like to have both motors run in opposite directions as in most applications. But no cigar.
I am thinking baud problem ?? Listed below is my code.
Thanks in advance.
'MY EXPEREMENT WITH Qik2s9v MOTOR CONTROLER.
' {$STAMP BS2}
' {$PBASIC 2.5}
'++++++++++ DECLARATIONS ++++++++
Baud CON 170
SO PIN 8 'INPUT to "qik"
RESET PIN 9 'RESET
' ********** Initialize ****
Setup:
HIGH SO
GOSUB Reset_qik
Reset_qik:
LOW RESET
PAUSE 1
HIGH RESET
RETURN
'********* MAIN *************
DO
SEROUT SO, Baud, 9, [0,0,0,127] 'M0 FORWARD.
SEROUT SO, Baud, 9, [0,0,1,127] 'M1 REVERSE.
PAUSE 2000
SEROUT SO, Baud, 9, [0,0,1,127] 'M0 REVERSE.
SEROUT SO, Baud, 9, [0,0,0,127] 'M1 FORWARD.
PAUSE 2000
LOOP
I have been working with a BS2 and a qik2s9v controller. I would like to have both motors run in opposite directions as in most applications. But no cigar.
I am thinking baud problem ?? Listed below is my code.
Thanks in advance.
'MY EXPEREMENT WITH Qik2s9v MOTOR CONTROLER.
' {$STAMP BS2}
' {$PBASIC 2.5}
'++++++++++ DECLARATIONS ++++++++
Baud CON 170
SO PIN 8 'INPUT to "qik"
RESET PIN 9 'RESET
' ********** Initialize ****
Setup:
HIGH SO
GOSUB Reset_qik
Reset_qik:
LOW RESET
PAUSE 1
HIGH RESET
RETURN
'********* MAIN *************
DO
SEROUT SO, Baud, 9, [0,0,0,127] 'M0 FORWARD.
SEROUT SO, Baud, 9, [0,0,1,127] 'M1 REVERSE.
PAUSE 2000
SEROUT SO, Baud, 9, [0,0,1,127] 'M0 REVERSE.
SEROUT SO, Baud, 9, [0,0,0,127] 'M1 FORWARD.
PAUSE 2000
LOOP
Comments
Also the green LED on the qik does not indicate communication with the BS2.
I think you are misunderstanding how the qik works. When in auto-detect baud mode, you can use any baud rate you want between 1200 and 38,400 bps. The qik will learn the baud rate when you send it the byte 0xAA (170 in decimal):
http://www.pololu.com/docs/0J25/4.b
- Ben
Thanks to all for the help.
http://www.pololu.com/docs/0J25/5
I don't have a sample program to give you, but I can tell you in words what you need to do:
1) Send the serial byte 0xAA (170) so the qik can learn the baud rate. If you do this successfully, you will see the blinking pattern of the green LED change.
2) Send the serial bytes: 0x88, 0x7F (or, in decimal: 136, 127). This will make the motor turn forward at full speed.
- Ben
Baud -170, Device ID - 9, 1st serial byte -0, Motor #- 0, Speed - 127.
This is all new to me. The only other time I have used the SEROUT command is with a serial LCD.
Don.
I don't have any experience with the SEROUT command, but after two minutes of googling around it looks like you should be able to do something like:
SEROUT SO, Baud, [170] 'baud indicator byte.
SEROUT SO, Baud, [136,127] 'M0 FORWARD full speed.
SEROUT SO, Baud, [136,63] 'M0 FORWARD half speed.
SEROUT SO, Baud, [138,127] 'M0 REVERSE full speed.
SEROUT SO, Baud, [140,127] 'M1 FORWARD full speed.
SEROUT SO, Baud, [142,127] 'M1 REVERSE full speed.
- Ben
Edit: By the way, you need to get the "Baud" constant right (it should not be 170!). You want to be using non-inverted TTL serial with 8 bits of data, no parity, and a baud rate between 1200 and 38,400 bps. Maybe someone on this forum can help point you in the right direction? I think you can get this by using a "Baud" constant 16468 (9600 bps), but I'm not sure.
Do understand non-inverted would be not holding Pin 8 high? I will try it both ways. I have a test code to try your suggestions in.
Thanks.
I don't mean to sound harsh, but I feel like you're not even trying to read the user's guide at this point. I don't think it could more explicitly explain what kind of serial signal the qik is expecting:
http://www.pololu.com/docs/0J25/4.a
You shouldn't need to "try it both ways"; there's plenty of detailed documentation out there, both on the qik and the Basic Stamp, that makes it easy to figure out the correct way. You just have to be willing to put in the effort to look for it and read it (and post very specific questions if there's something you don't understand).
- Ben
I noticed you are rather short with others on the "other" forum as well.
Don, how about you recognize that Ben has put some significant time into trying to help you?
Ben, how about you recognize that Don did say that he planned to try things? There's nothing wrong with a little trial-and-error.
The rest of us will all be impressed if you both manage to make your next posts be about the details of getting the device to work, and keeping them free of comments about each other's behavior, or defenses of your own behavior.
I'll bet you can both rise to the occasion. How about it?
Good thing it is a slow day here at work I have time to research this more.
" A man is not finished when he is defeated. He is finished when he quits."
I'm not an expert on the Basic Stamp (I think I might have programmed one once back in 1996) and I don't have one handy, which is why my guidance is limited to "shoulds", and I don't feel very compelled to spend even more time figuring something out for a person whose response to the time I've spent so far is a hypocritical accusation of "being on a high horse" followed by a criticism that I have not yet completed his project for him. It's not very endearing when the person you're trying to help demands:
My goal is not to do Don's project for him, it's to help him understand how to do it himself, and that requires he put forth some effort on his part rather than expecting me to physically try my suggestions, verify they work, and then give him the tested answer. Asking for help generally requires the recognition that (a) the person helping you is doing you a favor and (b) you need to work with that person to get your answer. Don, I hope you read this with an open mind and think about what I'm saying, because I think it can help ensure that your next request for help with a project goes much more smoothly. I wish you the best of luck getting your project up and running.
I definitely disagree with this point, at least in this particular case, and I stand by my attempt to strongly discourage it. I understand that there are times when trial and error is the best (or only) solution, but when the resources are there to understand what you're doing ahead of time, take ten minutes and do it right! Trial and error with electronics is a great way to destroy something. I've heard way too many people wonder why their device isn't working after they used trial and error to figure out how to connect power or some other peripheral ("It wasn't turning on, so I tried the wires the other way and smoke came out") rather than looking at the manual. It's a sloppy attitude to have when there are other much better recourses.
All of Don's problems in this thread can be traced back to that "trial-and-error" mentality, and in the end he would have saved so much time (both mine and his) if he had just read the qik user's guide and the Basic Stamp documentation for the SEROUT command! I completely understand that there might be residual confusion even after reading the documentation, and would welcome questions like "What does the user's guide mean when it says x?". My problem is not with the lack of understanding, its with the lack of effort and the sense of entitlement.
Just my thoughts, for whatever they're worth. I hope this doesn't come off as antagonistic because this is definitely not my intent. Once again, good luck with the project, and happy Thanksgiving!
- Ben
I accept your apology and am will remain in an open state of mind.
I should leave my work mentality at work as I do not accept "should be, should have" answers from my staff. That is not the view to have on a public forum. Especially when asking for help.
Although I do not fully agree with our view of trial and error.
I have been writing code for Allen Bradley PLC's for at least 10 tears and a lot of that is educated trial and error. Seldom does a block of code work exactly as you want the first time out. You build it, test it, adjust it.
I have studied the documentation on both the qik and BS2 and have came to the conclusion the problem is in the baud setting. I have ran your suggestions and what I have learned from the doc's. No progress so far. On the upside NO smoke.
I am going to leave this rest for a few days.
Happy Thanksgiving to all!
Don.