Shop OBEX P1 Docs P2 Docs Learn Events
Pixy2 code issues — Parallax Forums

Pixy2 code issues

pilot0315pilot0315 Posts: 985
edited 2025-09-20 04:59 in Robotics

@"Ken Gracey"
@"Aristides Alvarez"
@JonnyMac

Hey guys.
Just bought the pixy2. Demo code in Simple ide does not work. Simple ide will not open it.
The JM demo code in P1 won't open to the serial terminal. Added the ter.start as it was not there.
Propeller tool does not have the "jm_fullduplexserial" tried reverting it but there are subroutine calls that have differences that are too numerous to count. Tried to find the afore mentioned in github, forums, etc and only finde P2.
Spin Tools IDE does not support .side.
There are 7 download file categories. Finally found something in the files downloaded that appears to work. It is hidden under: 30028-pixy2 demo c code 2 24 2020.
Is there any P1 or P1 that works??
Lastly do you have the raw manuals with all the hex codes, commands and stuff for both.

Nojoy.
According the the downloads P2 demo code is there and is not.
Other than that the pixy2 looks great! But no demo code.
Awaiting demo code for the Husky cam as I got that too.
Any suggestions.
Thanks in advance.
Martin

Comments

  • That code worked five years ago when I wrote it -- and Ken and I did a lot of testing.

    I found P1 and P2 demos. I opened and adjusted for updates to libraries that have changed due to namespace conflicts with Spin2 (I tend to keep my Spin1 and libraries consistent with Spin2).

    I did not go looking for a PixyCam to retest; that's on you.

    I have provided P1 and P2 archives. Please unzip the archives and copy ALL of the libraries to your master library folder so you have the latest. I don't spend a lot of time worrying about updating ObEx, so you won't always find my latest code there.

  • pilot0315pilot0315 Posts: 985
    edited 2025-09-20 16:06

    @JonnyMac

    Thank you for your help.
    I understand the ObEx stuff, I will test the PixyCam and let you know.
    Also did the command codes come directly from the processor docs or was there a manual specifically for the Pixy?
    Martin

  • JonnyMacJonnyMac Posts: 9,752
    edited 2025-09-20 16:33

    If memory serves, I used the Pixy API as a guide and stuck as closely as I could without violating what I feel are best practices for Spin. For example, in the Pixy API you will find constants with "PIXY_" on the front -- we don't need those extra characters in Spin so I dumped them. The Pixy API uses camelCase for function names while my style uses snake_case, hence

    int8_t getVersion()
    

    becomes

    pub get_version() : result 
    

    You shouldn't have any problems connecting the Spin demos to the Pixy API docs if you'll be a bit patient. As I said, I delivered working code to Ken and he verified it.

    https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:full_api

  • Howdy everybody.
    I am trying again with the Pixy2
    None of the jm code works, sorry. I have tried the spin code in propeller tool and the spin tools ide. Just sits.
    The camera works as I am able to play with it and train it.
    The C code "demo c code 1-19 2020 is empty
    the same for 2-24-2020 "file not found"
    Any ideas from anybody for some simple code with explanations.
    I just want to see a block and identify it for object recognition.
    Thank you in advance.
    Martin

  • JonnyMacJonnyMac Posts: 9,752
    edited 2026-03-18 21:42

    None of the jm code works

    Yes, it does. I'm guessing...

    • You failed to configure the Pixy2 for serial coms at 19200
    • You failed to connect to the correct IO pins
    • You failed to connect P1.TX to Pixy.RX and P1.RX to Pixy.TX
    • You failed to follow configuration instructions in the comments of the demo

    • You failed to follow the run instructions in the main() method (see first screenshot).

    The attached screenshots show the Pixy2 running on a P1 -- the only thing I modified from the code I sent you months ago was the TX and RX pins used.

    The code works on Propeller Tool, Spin Tools, and even FlexProp.

    1920 x 1040 - 139K
    1918 x 1038 - 169K
    1918 x 1018 - 117K
  • JonnyMacJonnyMac Posts: 9,752
    edited 2026-03-18 14:26

    None of the jm code works

    Oh, look, it works on the P2 as well.

    Note that there was a CLS command that was removing the version, resolution, and frame rate information from the initial display, so I took that out -- otherwise, the code is as it has always been.

  • I was very careful to follow the instructions and pins.

  • Your code says error code 3 returned.
    The API has these errors:
    PIXY_RESULT_ERROR

    General error result
    PIXY_RESULT_BUSY

    This is returned when Pixy has no new data. It is used in polling mode, as opposed to blocking mode.
    PIXY_RESULT_CHECKSUM_ERROR

    This is returned when the data packet received contains a checksum error.
    PIXY_RESULT_TIMEOUT

    This is returned when Pixy2 has taken too long to return its result.
    PIXY_RESULT_BUTTON_OVERRIDE

    This is returned when the user is interacting with the button (e.g. teaching Pixy a signature) and can't perform the requested action.

    I went through your code and could not find error 3 nor an explanation.

  • JonnyMacJonnyMac Posts: 9,752
    edited 2026-03-19 13:56

    Shocker. Here we go again. You went from...

    None of the jm code works, sorry. I have tried the spin code in propeller tool and the spin tools ide. Just sits.

    to...

    Your code says error code 3 returned.

    Did you finally read the instructions that you have to press a key once the terminal is open? This code was written when Propeller Tool / PST was what most of us used, and I haven't done anything with it since.

    Here's what I get on my system with select #4 (the others work, too).

    It's possible that you have a device with different firmware with a modified API -- that's why I show that information in the initial screen.

    I went through your code and could not find error 3 nor an explanation.

    You mean this?

    When I wrote this program for Ken he and I both tested it and never had a communications error. Ken then deployed it in robot projects. If you have bad wiring, connections, or noise, there could be an issue. To save a cog for use in small P1 robots the serial code is not buffered (that is, the Pixy2 serial coms are in Spin1). In the P2 code I do use a serial cog so if you want to write a P1 driver using that model, be my guest.

    It was never Ken's intention nor mine to make this a full-fledged driver that enabled every Pixy2 feature -- it even says so in the object comments. There is also a link to the API page so that anyone wanting to do more than the basics knows where to get the correct information.

Sign In or Register to comment.