Shop OBEX P1 Docs P2 Docs Learn Events
Array of Sensors — Parallax Forums

Array of Sensors

CactiiCactii Posts: 14
edited 2008-03-29 23:58 in BASIC Stamp
I'm new to the Parallax community.

I picked up a Basic Stamp Homework Board because it was something that I had been wanting for a long time for a project that I would like to do.

One thing that I noticed right away though is how limited the projects are with regards to sensors and I/O channels.

I'm probably not very original in my idea but it is a challenge to myself to complete it.

I would like to build a sun tracking device using an array of 9 photo-resistors to control two servos which would give me a 2 axis tracker. The Basic Stamp Homework Board has enough I/O ports to easily accomplish this but I want to be able to use a small I/O footprint so that I may add on to the project at a later date.

I guess my question is this:

Is it best to deal with a large sensor array by developing a Basic Stamp daughter board around the Basic Stamp 1 or 2 Module and having it send feedback to the Main Projects' Basic Stamp board?

So I would have a Basic Stamp Homework Board that sends a signal to a Basic Stamp Module Board that is connected to my sensor array telling it to poll the sensors the program on that board would do all the calculations for the sensors and then send a signal back to the Basic Stamp Homework Board so that the it would utilize only one I/O channel for that whole array of sensors.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-29 20:59
    There are many ways to do this. You could use a co-processor as you suggested. You could also use an external switch (like an analog multiplexor) or a networked multichannel analog to digital converter like the Dallas DS2450.
  • CactiiCactii Posts: 14
    edited 2008-03-29 21:35
    Well, I like the coprocessor idea most because I really don't understand how the other ICs interact yet. I still need to work on that one. Plus it looks like if I start using other ICs then I will need to learn how to program in C as well.

    If you can show me a real world example of how I would set up a 9 sensor array with any one of those that you mentioned I would love to see it.

    Thanks for your reply.
  • CactiiCactii Posts: 14
    edited 2008-03-29 21:36
    So far I have the sensor array built on a breadboard and I've written a small program to poll the sensors. I need to expand on the program so that I can do some comparisons with the numbers that are returned.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-29 22:11
    The easiest thing to do at your level of expertise would be to use a BS2 as the co-processor and you can use the Homework Board to develop the software. Later you can use a BS2 module and some kind of carrier board like the Super Carrier Board.

    You essentially want 9 identical circuits for using the RCTIME statement for measuring the resistance of a photoresistor. Each one would use a different I/O pin. You have a program that measures the resistance of each in turn, then does any calculations for the sensors. You then use two I/O pins to connect this Stamp to the main one with 1K resistors in the leads to the other Stamp (for protection in case of programming errors). The main Stamp signals the coprocessor to send a set of data by changing one I/O pin from LOW to HIGH, then it waits at a SERIN statement for a response. After the SERIN finishes, it sets its signalling pin back to LOW. The coprocessor checks the corresponding I/O pin on every measurement cycle. If it's HIGH, it uses a SEROUT statement to send the data on the 9 sensors to the main Stamp, then waits for the main Stamp to change the pin back to a LOW before going to get the next set of measurements.
  • CactiiCactii Posts: 14
    edited 2008-03-29 22:26
    Yes, thanks, so far I have this and it seems to work fine. I still need to figure out how to compare the results of the readings. I know the program stores the data and then overwrites it every time but that is what I want it to do. I'm still not sure if I will store the data or compare it, depends on a few things that I am still learning about this language.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    'Variables
    pr1 VAR WORD
    pr2 VAR WORD
    pr3 VAR WORD
    pr4 VAR WORD
    pr5 VAR WORD
    pr6 VAR WORD
    pr7 VAR WORD
    pr8 VAR WORD
    pr9 VAR WORD

    DO
    GOSUB P_PRs
    PAUSE 2000
    LOOP


    P_PRs:
    HIGH 1
    PAUSE 100
    RCTIME 1, 1, pr1
    DEBUG DEC5 pr1, " ", CR
    WRITE 1, WORD pr1

    HIGH 2
    PAUSE 100
    RCTIME 2, 1, pr2
    DEBUG DEC5 pr2, " ", CR
    WRITE 3, WORD pr2

    HIGH 3
    PAUSE 100
    RCTIME 3, 1, pr3
    DEBUG DEC5 pr3, " ", CR
    WRITE 5, WORD pr3

    HIGH 4
    PAUSE 100
    RCTIME 4, 1, pr4
    DEBUG DEC5 pr4, " ", CR
    WRITE 7, WORD pr4

    HIGH 5
    PAUSE 100
    RCTIME 5, 1, pr5
    DEBUG DEC5 pr5, " ", CR
    WRITE 9, WORD pr5

    HIGH 6
    PAUSE 100
    RCTIME 6, 1, pr6
    DEBUG DEC5 pr6, " ", CR
    WRITE 11, WORD pr6

    HIGH 7
    PAUSE 100
    RCTIME 7, 1, pr7
    DEBUG DEC5 pr7, " ", CR
    WRITE 13, WORD pr7

    HIGH 8
    PAUSE 100
    RCTIME 8, 1, pr8
    DEBUG DEC5 pr8, " ", CR
    WRITE 15, WORD pr8

    HIGH 9
    PAUSE 100
    RCTIME 9, 1, pr9
    DEBUG DEC5 pr9, " ", CR
    WRITE 17, WORD pr9
    RETURN
  • CactiiCactii Posts: 14
    edited 2008-03-29 23:58
    I wrote my comparison subroutine to find the highest of 9 numbers... Wow... that is tough to do in PBasic...

    C_Nums:
    X = pr1
    move = 1

    IF X < pr2 THEN X = X
    IF X > pr2 THEN
    X = pr2
    move = 2
    ENDIF

    IF X < pr3 THEN X = X
    IF X > pr3 THEN
    X = pr3
    move = 3
    ENDIF

    IF X < pr4 THEN X = X
    IF X > pr4 THEN
    X = pr4
    move = 4
    ENDIF

    IF X < pr5 THEN X = X
    IF X > pr5 THEN
    X = pr5
    move = 5
    ENDIF

    IF X < pr6 THEN X = X
    IF X > pr6 THEN
    X = pr6
    move = 6
    ENDIF

    IF X < pr7 THEN X = X
    IF X > pr7 THEN
    X = pr7
    move = 7
    ENDIF

    IF X < pr8 THEN X = X
    IF X > pr8 THEN
    X = pr8
    move = 8
    ENDIF

    IF X < pr9 THEN X = X
    IF X > pr9 THEN
    X = pr9
    move = 9
    ENDIF
    RETURN

    Post Edited (Cactii) : 3/30/2008 12:08:19 AM GMT
Sign In or Register to comment.