Shop OBEX P1 Docs P2 Docs Learn Events
Can the BS1 do this — Parallax Forums

Can the BS1 do this

TCTC Posts: 1,019
edited 2006-07-22 01:46 in BASIC Stamp
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

Comments

  • TCTC Posts: 1,019
    edited 2006-07-21 03:40
    Just to add this. I was looking in the BS Manual and on page 123 under SYNCHRONOUS SERIAL I/O the BS1 & BS2 say they can do SHIFTIN, but on page 419 it says that only the BS2 can do SHIFTIN. Can the BS1 do SHIFTIN?

    TC

    PS. I am using manual 2.1
  • TCTC Posts: 1,019
    edited 2006-07-21 03:44
    Same thing in manual 2.2

    page 127 & 431
  • HarborHarbor Posts: 73
    edited 2006-07-21 04:08
    The BS1 does not provide a synchronous input as near as I can judge. (I've never tried, so I'm just going by the manual.) SHIFTIN on the other Basic Stamps provides a clock on one pin (set as output of course) and data is read in on another pin. The BS1 does do serial input, but only in asynchronous mode, using SERIN.

    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
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-07-21 04:40
    TC -

    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 -->
  • HarborHarbor Posts: 73
    edited 2006-07-21 05:00
    Can you keep up with the minimum clock rate on an ADC0831 by bit-banging a BS-1 Bruce? I wouldn't think you could. That's why I suggested the external clock.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-07-21 05:27
    Harbor -

    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 -->
  • HarborHarbor Posts: 73
    edited 2006-07-21 05:48
    Ah well, that's the test innit? If it works, it must be keeping up with the min clock, whatever that is. Something I read in that quick glance at the spec had me thinking you had to produce a pretty high clock rate to keep the ADC logic happy. Probably misread it.
  • TCTC Posts: 1,019
    edited 2006-07-21 12:19
    Harbor,

    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
  • HarborHarbor Posts: 73
    edited 2006-07-22 01:46
    You're welcome, TC. Anytime we can, we help each other.
Sign In or Register to comment.