Can the BS1 do this
![TC](https://forums.parallax.com/uploads/userpics/960/n1TI3FP1FAD2X.jpg)
I have done meny projects with the BS2 famly, but I am now working on a project that a BS1 would work best. I need to know if the BS1 can read an ADC0831? I could not find anything in the manual about the SHIFTIN for the BS1, Please help.
Thanks
TC
Thanks
TC
Comments
TC
PS. I am using manual 2.1
page 127 & 431
Offhand, looking at the spec of the ADC0831 I don't see any reason you couldn't provide an external clock pulse and control it from the BS1.
(And then you could use the SERIN command to read the data of course. That was what I meant.) You might be able to leave the clock running continuously, but I didn't read the spec of the ADC083x series closely enough to be sure of that.
It's simple to gate the clock pulse with an output from the BS1, so instead of using the SHIFTIN to create a clock pulse on one pin while accepting data on the other, you would assign one pin for CLK_Enable and make that high to gate the clock pulse to the ADC. Then the next command would be SERIN, and following the two data bytes, you would drop the CLK_Enable pin low to stop the clock. Of course, you have some signaling to do to prepare the ADC before starting the clock. (You sure you want to simplify by using a BS1 and then complicate by adding extra code and external logic? Just asking...)
Post Edited (Harbor) : 7/21/2006 4:14:33 AM GMT
Although SHIFTIN/SHIFTOUT are only supported on the BS-2 seris of PBASIC Stamps, you can still do synchronous serial input, but NOT with SERIN. SERIN can ONLY be used for ASYNCHRONOUS serial input.
The technique used is generally known as "bit banging" since you are synthesizing the necessary instruction (SHIFTIN) by using a couple of· primative Stamp operators. The access method uses a FOR-NEXT loop, and withinn that FOR-NEXT loop, you provide one clock pulse, and one access ("read") of the data input pin. This is done n times (8 in the case of the ADC0831) and thus you are able to read all n (8) bits of data. After each data bit is ADDED into a defined byte, the result is shifted to make room for the next bit. Thus, you are even responsible for establishing each bit position in the target data byte.
With all that in mind you can only imagine the rousing applause that was heard when the BS-2 was introduced and we learned about the new SHIFIN/SHIFTOUT commands. I'll see if I can loacte a proper and working example for you, to go along with the aboce explaination.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
To be perfectly honest, that thought never entered my mind. All I can tell you for sure is that it does work, as can be seen in Applications Note 2 in the attached Basic Stamp 1 Applications Notes from Parallax. Enjoy!
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
Thank you for responding I was going to try your idea until bruce showed us the AN
Bruce,
You just saved my first BS1 project, When you said "bit banging", I thought yea right for a basic hobbie programer, i'll just use a bs2. but after I see the AN I find out it is easyer than I thought, Thank you.
TC