Connecting and/or networking BS2 processors
stuartX
Posts: 88
Is there a way to connect two BS2 chips together so that one could send a condition to the other to perform a condition on it?
In other words, If BS2-1 has a sensor, (some condition is met) send that condition to BS2-2, and have BS2-2 perform some function?
In other words, If BS2-1 has a sensor, (some condition is met) send that condition to BS2-2, and have BS2-2 perform some function?
Comments
As a starting point, look in the Editor's helpfile under SERIN or SEROUT. There is a sample application there.
Cheers,
http://forums.parallax.com/showthread.php?110211-ABBot-Advanced-Boe-Bot
Great example.
All,
Thanks for all your quick help for a peon like me.
Much appreciated.
This will help move my robot project along.
Funny thing to see this post tonight as this was the subject of my torture (self inflicted) all week and tonight I managed to make 4 LED's blink when buttons are pressed on the master and boy was I happy!
Forgive me as I do not want to hijack the OP thread but thought my example might help us both...
I have 2 BS2 (OEM Boards) on a breadboard and wanted to make one talk to the other.
Master BS2 = 4 push-button's <----> Slave BS2 = 4 LED's
I am building (rebuilding!) a 1984 Tomy Omnibot 2000 into a more modern robot with 2 OEM BS2's (because it's what I have) and all the 'normal' Parallax peripherals. I need some way to teach myself how to not only program in PBasic but how to make the stamps "talk" to each-other. I have to admit that I searched the web and this forum for a full week before typing anything and am still not sure how I got it to work but it does. Next, I need to expand into controlling my drive motor (Paulou) serial motor controller via the buttons and then next step is a joystick... Baby steps!!
Stamp - Slave Test.bs2
Stamp - Master Test.bs2
So, I am a complete NOOB at coding and the only way I seem to understand this stuff is via "code snippets" or single purpose examples that I then combine into a bigger program, that being said I am SURE that the way I have managed to do this is inefficient and a waste of memory or something so ANY recommendations are greatly appreciated before I move to the next step. Also, the one thing I do not like about my current code is that if you press more then one button at once you get nothing so I am going to try to figure out the "button" command and see if that helps.
PS... My main reference was Jon Williams "A Tale of Two Stamps" Nuts & Volts #81 2002 http://www.parallax.com/Resources/NutsVoltsColumns/NutsVoltsVolume3/tabid/445/Default.aspx
Look forward to any feedback and have to say that I have no idea what I would do without this forum!
Jeff
Stavanger, Norway
I can send a byte (cmd) to the slave for example "1 = move forward" but on the slave how should I (best method) for program to receive the command (button press) and be able to "loop" to check for the button being pressed / released and if there is a new command being sent?
' receive command byte from master (push button)
' ' ' do as instructed (keep moving while button is held down)
' loop around and check for button release and if there is a new button being pressed
Also in the future there will be sensors to be checked and other functions to perform so understanding how do I code the "receive input" / "perform action" and which of the 2 stamps will perform what and when is crucial to me.
Thanks for any feedback!
What I usually do is set up the receiving end to constantly loop and use the timeout and WAIT functions to help make sure the SERIN is ready when the data arrives. Once a command is received, you can signal the master that the message was received then let the slave act on the command before going back to wait for the next command.
The timeout function lets the slave check on things if no data is received (but be aware, any incoming data, whether real or noise will keep resetting the timeout and the slave will never go do the housekeeping).
So how do you recommend that I "distribute" the processes on a 2 stamp "big Boe-Bot" setup? should I put the motor control, ping and avoidance/collision decisions on 1 and the LCD, PIR, sound, etc, etc. on the other? I have been trying to interpret the Advanced Boe Bot code listed above and need to understand it better.
I think you'll quite quickly get to the point where you'll have a two-way link between the Stamps. The master sends commands to the slave who does the action then sends back sensor data for the master to act on.
You can see one control scheme I've done on www.youtube.com/stamptrol1 Its the third one listed, I believe.
And, like most concepts, its better to gradually work through the challenges in stages rather than trying to come up with a multi-part solution in one go.
I'd suggest getting a solid comm link going, then send data back and forth and finally add the control aspects.
Very good post (for me). The project that you have brought in a better understanding of the connectivity and code of how it works. I have to take baby-steps into it. Once I receive my second BS2 I'll connect it up.
Stamptrol,
I'll take your advice also and try a few things. I'll review your youtube.
Thanks again. This is very, very helpful. I'll stay posted for more information.
I will say that I was going about this wrong in that I was in such a hurry to make the 2 stamps "talk" that I forgot to have a plan for what I wanted to accomplish.... so back to the design stage to divide up the process and steps - the Advanced Boe Bot is a great example!
What I'm doing/learning right now is not so dissimilar from what you guys are doing. Except I'm including a PC for the main brains of the thing. So I have three parts to deal with (the PC, the Stamp(s), and the output. Breaking it down into steps/parts to learn a particular function/instruction is basically the same as writing subroutines that will all get combined in the end. You'll know your code better and it keeps you from getting overwhelmed by the full program. You can't build a car until you know how to build an engine, transmission, wheels, etc.
I'm going to follow this thread, since ultimately it will help me when I too start networking multiple stamps. Right now I have just the PC to Stamp to Output and back. One can never have too many stamps.
Thanks for the advice. I'm trying to get into and understand interfacing the stamp with a PC, so all your advice is soaking in for me. I'm not a programmer, but I try to figure things out. It just may take me a little longer.
Just like programming the modular approach works. I try to work on one piece of the puzzle at a time then work my way up. Once all the worked out pieces are together then I try to debug the collective.....lol fun.
I learn by my mistakes, do research and from you all.
@All,
Thanks for the input this is good stuff. I have a few projects on the table in which its helping with all of them.
Thinking about setting up the joystick in a "remote control" box for my robot that will send some bit/pulse/trigger to tell the master BS2 when it is turned on and ready to send commands so that the stamp will "listen" for the "Manual Override" commands from the remote. I will do this "wired" first go round and then figure out "wireless" next and this is to allow for remotely controlling an arm that will be on the bot and driving around just for fun via remote.
So StuartX how is your project proceeding?
Components in this code example;
OEM BS2, 2-Axis Joystick #27800, Pololu SMC20B Motor Controller, 2 6v DC motors
I received the stamp and hook up the circuit. I only hooked up three switches and three LEDs (pin 10, 11, 12)
When I pressed buttons I did get the response........cool! This will solve alot of problems.
It was strange but LED @pin 12 constantly blinked until I pressed switch pin10 or 11. Then LED @pin 12 continued to blink. There seem like a delay. Is this due to the fact that the BS2 doesn't have multiple cogs?
But, at any rate, i'm sifting through the code to understand it better. Thanks Jeff this opens up a lot of possibilities.
I'm working on two projects, LED lighting in the house (two flights of stairs, foryer, hallway, MBR short hall). The second project is the robot. I receive my sonar sensors and I will be hooking them up on the board and testing trying to figure out code.
By the way, I'm going to be trying to test my autonomous to manual mode, but in a different way.
Keep me posted.
Hey sounds like you are having fun!! Let me know if I can help with the code at all and if you get it going. I have been busy with work stuff... maybe this weekend a bit more playing with the stamps!