​ ​ ​ ​ sertxd and PIXY CMUcam5 - Page 2
Page 2 of 2 FirstFirst 1 2
Results 11 to 20 of 20

Thread: sertxd and PIXY CMUcam5

  1. #11
    Senior Member
    Join Date
    Jul 2014
    Location
    Earth - United States - Nevada - Las Vegas
    Posts
    115

    Default

    Hi,

    Okay, here's the FatBelly code;

    ; 28X2+PIXYcam5-Serial-FatBellyMaster.bas

    #picaxe 28X2 ; type chip used
    #terminal 9600

    ; Declare and Initialize Variables and Constants * * * * * * * * * * * * * * *
    symbol RWheel = B.0
    symbol LWheel = B.1

    symbol RLED = B.7
    symbol GLED = B.6
    symbol BLED = B.5

    ; Serial IN = PIN 8 of 28X2 module to PIN 1 of PIXY CMUcam5 Grey Cable
    ; SerialOUT = PIN 9 of 28X2 module to PIN 4 of PIXY CMUcam5 Grey Cable

    Symbol RX_PIN = C.3
    Symbol RX_BAUD = T9600
    pause 2000
    SerTxd(CR, LF)

    ; hserout pin = C.6
    hsersetup B9600_8, %00000 ; 9600 baud, non-inverted polarity

    init: servo RWheel,150
    servo LWheel,150

    ; BEGIN Main Body * * * * * * * * * * * * * * *
    ;pause 5000

    gosub Cntr
    gosub Speech1

    Do
    ;debug
    SerIn RX_PIN, RX_BAUD, ($AA), b1, b3,b2, b5,b4, b7,b6, b9,b8, b11,b10, b13,b12

    sertxd ("The 1st data is ",#b1,13,10)
    SerTxd (#b1, #b3,#b2, #b5,#b4, #b7,#b6, #b9,#b8, #b11,#b10, #b13,#b12)

    Select Case b1
    Case $55 : SerTxd( "Normal")
    Case $56 : SerTxd( "Color")
    Else : SerTxd( "Unknown")
    End Select
    SerTxd( " Checksum=" , #w1 )
    SerTxd( " Signature=" , #w2 )
    SerTxd( " X=" , #w3 )
    SerTxd( " Y=" , #w4 )
    SerTxd( " Width=" , #w5 )
    SerTxd( " Height=" , #w6 )
    SerTxd( CR, LF )

    IF w3<90 then gosub Left
    IF w3>110 then gosub Right

    IF w2 = 257 then gosub RWarn
    IF w2 = 258 then gosub GWarn
    IF w2 = 259 then gosub BWarn

    gosub Cntr
    gosub Fun
    pause 1000
    gosub Learn

    Loop

    ; BEGIN SpeakJet Talking & Singing Subroutines * * * * * * * * * * * * * * *
    Vocal: ; Vocal Test, second vocal test
    ; \PITCH \100 \VV \OW \KE \AW \LE Test , , second , \PITCH \95 \VV \OW \KE \AW \LE \PITCH \100 test
    gosub red
    pause 500
    gosub green
    pause 500
    gosub blue
    pause 500
    gosub Orange
    gosub Cntr
    hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 22, 100, 166, 137, 194, 135, 145, 191, 131, 8, 187, 191, 2, 2, 8, 187, 131, 195, 133, 141, 177, 2, 22, 95, 166, 137, 194, 135, 145, 22, 100, 191, 131, 8, 187, 191)
    pause 3500
    return

    Speech1:
    ; Hello, My name is Turner
    ; Hello, My name is pick see Bot
    gosub green
    hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 183, 7, 159, 146, 164, 2, 140, 155, 141, 154, 140, 8, 129, 167, 8, 191, 151, 141, 148)
    pause 3500

    ; I am a PIXYbot
    ; I am a pick see Bot
    gosub green
    hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 132, 132, 140, 154, 128, 198, 129, 195, 187, 187, 128, 128, 6, 171, 8, 136, 191)
    pause 3500

    ; I have a RoboGuts circuit board
    ; I have a \RR \OW \BO \OW \GE \AW \TT \Slow \SE \SE \RR \KE \EH \TT \BO \OW \RR \DE
    gosub Teal
    hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 183, 8, 132, 166, 154, 128, 148, 137, 171, 137, 178, 135, 191, 8, 187, 187, 148, 194, 131, 191, 171, 137, 148, 174)
    pause 3500

    ; I have a PICAXE 28X2 module
    ; I have a pick ax twenty eight X two \MM \AW \JH \UH \LE
    gosub Teal
    hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 183, 8, 132, 166, 154, 128, 198, 129, 195, 132, 132, 196, 187, 8, 7, 191, 7, 147, 131, 141, 7, 191, 128, 154, 4, 191, 131, 131, 195, 187, 8, 191, 162, 140, 135, 165, 138, 145)
    pause 4000

    ; I have a PIXY CMUcam5 camera
    ; I have a pick see C M U \KE \AY \MM five \KE \AY \MM \RR \AW
    gosub Pink
    hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 183, 8, 132, 166, 154, 128, 198, 129, 195, 187, 187, 128, 128, 6, 187, 187, 128, 128, 6, 131, 131, 140, 6, 8, 160, 6, 194, 132, 140, 6, 186, 157, 166, 6, 194, 132, 140, 148, 135)
    pause 5000

    ; Shall we play a game
    ; \PITCH \90 Shall \PITCH \95 we \PITCH \90 play \PITCH \85 a \PITCH \100 game
    gosub green
    hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 22, 90, 189, 8, 132, 8, 146, 22, 95, 147, 8, 128, 22, 90, 199, 7, 145, 131, 154, 22, 85, 154, 128, 22, 100, 8, 178, 154, 140)
    pause 3500
    return

    Attack:
    ; Attack, attack, attack
    ; \AW \TT \AY \KE \AW \TT \AY \KE \AW \TT \AY \KE
    hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 135, 191, 132, 194, 135, 191, 132, 194, 135, 191, 132, 194)
    pause 2000
    return

    Fun:
    ; This is fun, give me another color
    ;
    gosub red
    hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 8, 169, 8, 129, 187, 8, 129, 167, 186, 8, 134, 141, 2, 8, 178, 8, 129, 7, 166, 140, 128, 128, 134, 141, 134, 169, 151, 195, 8, 134, 146, 7, 151)
    pause 2000
    return

    RWarn:
    ; I see red
    ;
    gosub red
    ;hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 187, 187, 128, 128, 148, 8, 131, 176)
    pause 1000

    sertxd ("Red Data is ",b1, #b3,#b2, #b5,#b4, #b7,#b6, #b9,#b8, #b11,#b10, #b13,#b12,13,10)
    return

    GWarn:
    ; I see green
    ;
    gosub green
    ;hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 187, 187, 128, 128, 8, 179, 7, 148, 8, 128, 141)
    pause 1000

    sertxd ("Green Data is ",b1, #b3,#b2, #b5,#b4, #b7,#b6, #b9,#b8, #b11,#b10, #b13,#b12,13,10)
    return

    BWarn:
    ; I see blue
    ;
    gosub blue
    ;hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 187, 187, 128, 128, 171, 7, 146, 162)
    pause 1000

    sertxd ("Blue Data is ",b1, #b3,#b2, #b5,#b4, #b7,#b6, #b9,#b8, #b11,#b10, #b13,#b12,13,10)
    return

    Learn: ; Learn to be a Geek
    ; \PITCH \100 \LE \Slow \RR \PITCH \90 \NE to \BE \IY a \PITCH \100 \GE \IY \KE
    gosub blue
    gosub FWD
    hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 22, 100, 145, 8, 148, 22, 90, 141, 6, 8, 191, 162, 170, 128, 154, 128, 22, 100, 178, 128, 194)
    pause 3000
    return
    ; END SpeakJet Talking & Singing Subroutines * * * * * * * * * * * * * * * *
    end

    ; BEGIN Standard Servo Subroutines * * * * * * * * * * * * * * * * * * * * * *
    ; PWMOUT pin, period, duty cycles
    ; Wheels
    Cntr:
    servopos RWheel, 150
    servopos LWheel, 150
    return

    FWD:
    servopos RWheel, 130
    servopos LWheel, 170
    return

    BAK:
    servopos RWheel, 165
    servopos LWheel, 135
    return

    Right:
    servopos RWheel, 125
    servopos LWheel, 125
    return

    Left:
    servopos RWheel, 175
    servopos LWheel, 175
    return
    ; END Standard Servo Subroutines * * * * * * * * * * * * * * * * * * * * * **
    end
    ; BEGIN RGB LED subroutines * * * * * * * * * * * * * * *
    LEDsOFF:
    high RLED
    high GLED
    high BLED
    return

    red:
    low RLED
    high GLED
    high BLED
    return

    green:
    high RLED
    low GLED
    high BLED
    return

    blue:
    high RLED
    high GLED
    low BLED
    return

    Pink:
    low RLED
    high GLED
    low BLED
    return

    Orange:
    low RLED
    low GLED
    high BLED
    return

    Teal:
    high RLED
    low GLED
    low BLED
    return
    ; END RGB LED subroutines * * * * * * * * * * * * * * * *
    end

  2. #12
    Technical Support
    Join Date
    Jan 1970
    Location
    UK
    Posts
    24,438

    Default

    Quote Originally Posted by SolidWorksMagi View Post
    Okay, here's the FatBelly code
    If that code works as expected with the setup you are currently using there is no obvious reason why your code in post #1 and the simpler code in post #5 does not.

    For the FatBelly code to run the CMUCam5 has to be putting out $AA bytes and checking for those is all the post #5 code does.

    There is no obvious reason why the $AA bytes would be produced with the FatBelly code but not with the post #5 code. In fact it would not seem unreasonable to say that would be impossible.

    But things sometimes can be weird. I would suggest running the FatBelly code and checking that works as expected. Then take code out a chunk at a time and check that everything else still works. Keep trimming it back until you are down to the bare minimum, have the equivalent of what Post #5 is.

    That will either have post #5 work as it would have been expected to, or reveal what was removed which causes things to stop working.

  3. #13
    Senior Member
    Join Date
    Jul 2014
    Location
    Earth - United States - Nevada - Las Vegas
    Posts
    115

    Default

    Quote Originally Posted by hippy View Post
    If that code works as expected with the setup you are currently using there is no obvious reason why your code in post #1 and the simpler code in post #5 does not.

    For the FatBelly code to run the CMUCam5 has to be putting out $AA bytes and checking for those is all the post #5 code does.

    There is no obvious reason why the $AA bytes would be produced with the FatBelly code but not with the post #5 code. In fact it would not seem unreasonable to say that would be impossible.

    But things sometimes can be weird. I would suggest running the FatBelly code and checking that works as expected. Then take code out a chunk at a time and check that everything else still works. Keep trimming it back until you are down to the bare minimum, have the equivalent of what Post #5 is.

    That will either have post #5 work as it would have been expected to, or reveal what was removed which causes things to stop working.

    Hi,

    Essentially that's what I did. All I did was change out the "robot body and face plastic parts" for new plastic parts to allow the camera to tilt up 'n down and cut out the "case statement, LEDs and motor subroutines" for testing.

    When I didn't see anything, I reprogrammed the FatBelly program into the bot and watched as I change different color pieces in front of the camera and the appropriate color LED turned ON and the robot voiced out the correct color too.

    Which is why I opened up this thread ... something is wrong and I don't understand enough.

  4. #14
    Technical Support
    Join Date
    Jan 1970
    Location
    UK
    Posts
    24,438

    Default

    Quote Originally Posted by SolidWorksMagi View Post
    something is wrong and I don't understand enough.
    I don't think anyone else will know any more. What you did should have worked.

    We know going from what you had to what you have hasn't worked, so make that a smaller jump.

    Take out a chunk and check if it works or doesn't. If it works then you are okay so far, carry on removing something else.

    If it stops working, add what was removed back in, take out a smaller chunk, repeat until it comes down to adding or removing a single line.

    It might be a long and laborious process but depends on how big the chunks are which can be removed without things failing. First thing to do is put a SERTXD after the SERIN so you know it's working. Then you can tear out the speech stuff, then the LED stuff. That should reduce things quit quickly.

    Unfortunately I cannot think of any other approach. It's what I have had to do myself at times.

    If you have a scope I guess you could put that on the serial line, see if the $AA's are being sent to the PICAXE, check they are arriving on the C.3 pin. If they are and post#5 doesn't work, we may be able to figure that out more easily.

  5. #15
    Senior Member
    Join Date
    Jul 2014
    Location
    Earth - United States - Nevada - Las Vegas
    Posts
    115

    Default

    Hi,

    All I did was add the terminal setup and one line to send the data from the FatBelly program to the terminal;

    SerTxd (#b1, #b3,#b2, #b5,#b4, #b7,#b6, #b9,#b8, #b11,#b10, #b13,#b12)

    Still no data comes from the PICAXE 28X2 to the terminal other than some basic text in the lines before the data collection serin command.
    Last edited by SolidWorksMagi; 12-08-2018 at 18:56.

  6. #16
    Senior Member
    Join Date
    Jul 2014
    Location
    Earth - United States - Nevada - Las Vegas
    Posts
    115

    Default

    Quote Originally Posted by hippy View Post
    I don't think anyone else will know any more. What you did should have worked.

    We know going from what you had to what you have hasn't worked, so make that a smaller jump.

    Take out a chunk and check if it works or doesn't. If it works then you are okay so far, carry on removing something else.

    If it stops working, add what was removed back in, take out a smaller chunk, repeat until it comes down to adding or removing a single line.

    It might be a long and laborious process but depends on how big the chunks are which can be removed without things failing. First thing to do is put a SERTXD after the SERIN so you know it's working. Then you can tear out the speech stuff, then the LED stuff. That should reduce things quit quickly.

    Unfortunately I cannot think of any other approach. It's what I have had to do myself at times.

    If you have a scope I guess you could put that on the serial line, see if the $AA's are being sent to the PICAXE, check they are arriving on the C.3 pin. If they are and post#5 doesn't work, we may be able to figure that out more easily.

    Hi,

    I tried adding lines to the FatBelly program but never get anything back on sertxd after the serin line ??? You can see the various lines I used trying to get data to the terminal window below;

    Do
    SerIn RX_PIN, RX_BAUD, ($AA), b1, b3,b2, b5,b4, b7,b6, b9,b8, b11,b10, b13,b12

    sertxd ("The 1st data is ",13,10)
    ;SerTxd ($AA),(#b1, #b3,#b2, #b5,#b4, #b7,#b6, #b9,#b8, #b11,#b10, #b13,#b12)
    ;SerTxd (#b1, #b3,#b2, #b5,#b4, #b7,#b6, #b9,#b8, #b11,#b10, #b13,#b12,13,10,13,10)
    SerTxd (b1, b3,b2, b5,b4, b7,b6, b9,b8, b11,b10, b13,b12, 13,10,13,10)

    loop

  7. #17
    Technical Support
    Join Date
    Jan 1970
    Location
    UK
    Posts
    24,438

    Default

    Quote Originally Posted by SolidWorksMagi View Post
    I tried adding lines to the FatBelly program but never get anything back on sertxd after the serin line ???
    That seems to suggest the modified FatBelly program isn't working.

    It is getting unclear what does work and what does not. Does the original, unmodified, FatBelly program work as expected using your current hardware ?

    If not then the CMUcam5 is not sending $AA or the PICAXE is not seeing that.

    If it does work but adding a SERTXD stops it working then I am not sure what is going on. Perhaps power-cycle, hard reset, everything including the CMUcam5.

  8. #18
    Senior Member
    Join Date
    Jul 2014
    Location
    Earth - United States - Nevada - Las Vegas
    Posts
    115

    Default

    Quote Originally Posted by hippy View Post
    That seems to suggest the modified FatBelly program isn't working.

    It is getting unclear what does work and what does not. Does the original, unmodified, FatBelly program work as expected using your current hardware ?

    If not then the CMUcam5 is not sending $AA or the PICAXE is not seeing that.

    If it does work but adding a SERTXD stops it working then I am not sure what is going on. Perhaps power-cycle, hard reset, everything including the CMUcam5.


    Hi,

    The original FatBelly program only gets the color ID number from the camera. The PIXY CMUcam5 documentation seems to imply that all sorts of data about the color besides color ID is sent though the serial port, so far it seems only the color ID is sent which is what the FatBelly program uses.

    I'm giving up on that for now, but trying to read the two Pan&Tilt servos connected to the PICAXE 28X2 module instead. This might work for the project instead. But when using the following program I only get "0" for the two results?

    #picaxe 28X2 ; type chip used
    #terminal 9600
    pause 1000
    sertxd ("Terminal Initiated ",#b1,13,10)

    ; Declare and Initialize Variables and Constants * * * * * * * * * * * * * * *
    symbol RWheel = B.0
    symbol LWheel = B.1

    init: servo RWheel,150
    servo LWheel,150

    do
    pulsin RWheel,1,w1
    pulsin LWheel,1,w2

    sertxd (" Pan/LServo = ",#w1, 13,10)
    sertxd (" Tilt/RServo = ",#w2 ,13,10)

    loop

  9. #19
    Technical Support
    Join Date
    Jan 1970
    Location
    UK
    Posts
    24,438

    Default

    Quote Originally Posted by SolidWorksMagi View Post
    when using the following program I only get "0" for the two results?
    Presumably because no pulses are being seen on the B.0 and B.1 pins.

  10. #20
    Senior Member
    Join Date
    Jul 2014
    Location
    Earth - United States - Nevada - Las Vegas
    Posts
    115

    Default

    Quote Originally Posted by hippy View Post
    Presumably because no pulses are being seen on the B.0 and B.1 pins.

    Hi,

    But servo motors on B.0 and B.1 are spinning as I move a color dot around in front of the PIXY CMUcam5 now I get a ton of directional data that I can use. I just have to sort it out a little.
    Last edited by SolidWorksMagi; 15-08-2018 at 00:02.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •