Multitasking Basic Stamp
MrRedHair
Posts: 9
Electronics, programming, and robotics is a hobby of mine that I enjoy. Recently, I made a program for my Boe-Bot that detects IR signals from an IR TV Remote using the rctime command, then, depending on the signal, moved or reacted however it was told. The program was successful but I did run into an inherent problem that goes with the basic stamp modules. They can only perform one task at a time. The stamp couldn't receive and analyze the signal at the same time as telling the servos what to do. I had to compromise with making movement subroutines that moved the servos for small set amounts of time, instead of my original idea of moving the bot while it received a signal from the IR TV remote. My question is: can you use a second stamp, stamp2, to look for the IR signal, analyze it, and have it send another signal to stamp1 with what to do? In effect, making a multitasking basic stamp that can run the servos while receiving the signal, instead of running the short subroutines every time the signal is detected.
If needed, I can post the code for the program.
If needed, I can post the code for the program.
Comments
If you specifically want to use two Stamps to handle this, make the IR remote handling Stamp the master and the servo controller the slave, partly because the servo controller would be on a fixed 20ms cycle and can check for new data from the IR remote handler every cycle.
I'm particularly interested in setting up the multi-stamp array because I plan on using sensors and servos I have around to expand this bot into something bigger and better, but powered by BASIC, and so the additional stamps would most definitely help in this task.
You'd do something similar to this if you were using two Stamps instead. The IR Stamp would set an I/O pin high with the guarantee that the servo Stamp would see that within 20ms. The servo Stamp, instead of using a PAUSE 20 to create the 20ms servo control cycle, would use something like PAUSE 1 repeated 20 times with a test for this I/O pin being high. If high, the servo Stamp would set a 2nd I/O pin high as a signal back to the IR Stamp and immediately drop into a SERIN statement to wait for data from the IR Stamp which would then transmit data (using SEROUT) to the servo Stamp and both Stamps would change their I/O pins to low.
If you want to do a multi-Stamp network, have a look at the Nuts and Volts Columns. There's a two column piece on networking several Stamps together.
Another idea: With two stamps, instead of using the IR Remote to control the robot, can you use one stamp with a PING))) sensor to constantly pan back and forth to detect walls and such while the stamp2 has the servos moving? In effect: to make a maze-navigating robot that doesn't have to stop every time it wants to pan the PING))) around to detect surrounding walls. When the PING))) detects a wall, the servos change from forward to turn immediately, no need to stop.
http://forums.parallax.com/showthread.php?130927-Low-Tech-IR-Remote
Again, look at the examples in the Nuts and Volts Columns and in the Stamp Manual chapters on the SERIN and SEROUT statements.
Bonjour, (Traduction Google) en espérant que vous pourrez le lire
Pour créer une ou des applications multitâches avec un Basic Stamp 2p24 / 40, j'ai réalisé une applications utilisée en niveaux industrielle, c'est le partage temporelle avec un système de comptage effectué par une boucle sans fin (à chaque IF ou entre chaque IF, une application s'exécute).
Un comptage rapide pour les appels rapides, un comptage lent pour les applications lentes.
Il faut initialiser une variable (sûrement une déclaration Word, Byte étant trop court)
bcl var word ' (65535 pas de comptage)
' Ayant déclarer la dite variable bcl, pas besoin de la mettre à zéro
' Puis,
Start: ' étiquette de démarrage
if bcl = 17 then .... fonction 1 choisie
if bcl = 220 then .... fonction 2 choisie
if bcl = 1000 then .... fonction 3 choisie
if bcl > 20 and bcl < 50 then ...
bcl = bcl + 1 ' incrémenter le pointeur
' soit on remet la variable bcl à zéro ( IF bcl > nmax then bcl = 0)
' ou on attend que le comptage dépasse la valeur Word (65535 pas)
goto start: ' refaire un tour indéfiniment
Cela ma permis de créer un feux de signalisation feux rouge (5 secondes), orange (2 secondes), vert (3 secondes) avec une fonction multitâche consistant à activer une led bleue qui clignote toute les secondes pendant 0.5 secondes sans utiliser une seules PAUSE n dans le programme, rien qu'avec le comptage d'un compteur en boucle, des IF pour activer toutes les fonctions. Le processeur travail au maximum dans une boucle, ce système permet d'ajouter des fonctions imprévues aux départ, il faut juste re-calibrer la valeur des IF pour compenser une nouvelle charge du à une perte de vitesse.
Le processeur BS2p24 a une cadence de environ 12000 opérations par secondes
Je peut vous fournir une petite vidéo si vous le désirer.
Alain Pilloud, ing. industrielle
pilloud.alain.123456789@gmail.com
Ce jour, 11.11.2023
Oui, that's the extent of my french
Hello!
Remember that's a French response to a complicated sequence of events from many years earlier. In fact, we still don't know if the opener to this difficult one was successful. Or where Mr. Green is today even.
Reply created with the help of two mascots.