Shop OBEX P1 Docs P2 Docs Learn Events
Project help, ColorPAL code integration — Parallax Forums

Project help, ColorPAL code integration

M.W.M.W. Posts: 8
edited 2010-03-10 05:33 in BASIC Stamp
Hey Forum,

I am working on my final project using a BS2, Propeller Servo Controller and ColorPAL. I found a piece of starter code that is exactly what I am trying to do, but it's designed for a different color sensor (Taos). I have been trying to rewrite the code so that it will use the ColorPAL instead but I am having no luck. I was hoping that someone who knows more about this could tell me what I am doing wrong. I am attaching the code that I am using. Props to the people who originally wrote it.

Also, slightly disappointed with the ColorPAL's sensor range, only about half an inch... but we work with what we have right?

Anyway, thanks in advance!

EDIT: Forgot to say what the code does. It's supposed to control a robotic arm that picks up colored blocks from one location and sorts them by color into cups.
EDIT2: Posted code updated thanks to PhiPi's recommendation. TY!

Post Edited (M.W.) : 3/4/2010 5:44:39 AM GMT

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-02-27 21:47
    Since this is a school project, I'm not going to write your code for you. But let's discuss this block of code from your program:

    GetColor:
      SEROUT sio, baud, [noparse][[/noparse]"= (00 $ m) !"]  'Program ColorPAL to send $ then color data.
    DO
      SERIN sio, baud, [noparse][[/noparse]WAIT("$"), HEX3 RED, HEX3 GREEN, HEX3 BLUE] ' Receive RGB data back
    LOOP
    'DEBUG "RGB: "
    'DEBUG DEC3 RED, " "
    'DEBUG DEC3 GREEN," "
    'DEBUG DEC3 BLUE, CR
    'DEBUG CR
    RETURN
    
    
    


    First, the SEROUT part only needs to be done once, at the beginning of your program. This programs the ColorPAL to send color data continuously, so it doesn't need to be repeated each time you want to get a sample.

    Next, your DO .. LOOP construct will never exit, so your subroutine will never return. You don't need the loop there at all.

    'Hope this helps. Good luck with your project!

    -Phil
  • M.W.M.W. Posts: 8
    edited 2010-03-03 01:43
    Ah, good, thank you for your reply. That's something I think I never would have noticed. So I have made some changes that I feel are appropriate thanks to the reply I have gotten. I do have a direct question though; does the ColorPAL need a place to store the color information or does it do that automatically as it continuously scans for color?

    Thank you!
  • M.W.M.W. Posts: 8
    edited 2010-03-04 05:22
    Ok, so I have tried the code out with all the working parts. Some of it works and some does not. I have re-attached the changed code to my first post.

    Here's the problem I think I'm having, I think the ColorPAL is not coming on at all. I have tried putting the SEROUT command in multiple places, but the LED never turns on inside as it tries to sample the color. The servo controller seems to work, as do the servos. I think right now the only thing holding me up is that ColorPAL. I am going to search for more documentation but if anyone has any pointers that would be great.

    Also, I don't see a command that lets me step through my code [noparse][[/noparse]to see if I am ending up in an endless loop or something] for the stamp editor that Parallax provides. Is it there and I don't see it or should I try a different compiler?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-03-04 06:56
    When the ColorPAL is sampling colors, the RGB LED barely appears to light up, since it's pulsing on so briefly and quickly. In a darkened room do you see any LED activity at all? Does your GetColor routine return when you call it? (If it does, that means it's getting color data from the ColorPAL.) How about the ColorPAL demo program: does it work correctly?

    -Phil
  • M.W.M.W. Posts: 8
    edited 2010-03-04 16:07
    Hey, the demo programs work. I will hook it all up again tonight and see if I can see the activity in the LED and run a debug on my GetColor routine. I am fairly confident that I am just one or two mistakes away from making this work right.
    Thank you for your continued help Phil, seems you're the resident expert on ColorPAL. I noticed your name in some of the sample code that Parallax provides, pretty cool [noparse]:)[/noparse] So I will post results tonight. TY again.
  • M.W.M.W. Posts: 8
    edited 2010-03-10 05:33
    Final update, the code worked great with a few more modifications. Unfortunately my teammates had taken the ColorPAL home to machine a bracket for it so I didn't get a chance to test again until the due date. I made a few adjustments to the code and it worked fine.

    Did have a little problem with the weight of the arm vs. servo torque though, but that is something of a different matter.

    Thanks for your help! Attached is my final code, some of it has been simply rerouted to make it function more succinctly.
Sign In or Register to comment.