PIXY CMUcam5 and PICAXE 28X2 module ...

SolidWorksMagi

Senior Member
Hi,

I setup a basic serial in/out loop but I don't see any data ??? The Serial IN/OUT pins of the 28X2 are jumpered to the gray cable from the PIXY CMUcam5

28X2 to PIXY
2 to 1
1 to 4

I have the PIXY CMUcam5 I/F setup for SPI with SS at 9600 8N1 Baud

20160914-PIXY-SerialSetup.jpg



Got any clues why I can't data from the PIXY CMUcam5?

#picaxe 28X2 ; type chip used
#terminal 9600

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

Do
;----------------------------------------Sig#----XPos---YPos------Width------Height===========The data Bytes I want to retrieve
SerIN 2,T9600_8,b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17

SerTXD ("PIXY say's; ",b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17)

pause 10
Loop

IF I comment out the SerIN command all I ever see on the terminal window is "PIXY say's; " over and over ... otherwise I do not seem to be receiving any info from the PIXY CMUcam5 and SerTXD doesn't send anything back to the #Terminal window ???


I want to make a new toy!
 
Last edited:

inglewoodpete

Senior Member
The SerIn command is waiting for data. It must receive 17 bytes before execution moves on to the next instruction. You are probably sending the data into another pin.

SerIn 0,..... is an outmoded syntax, not normally used on a 28X2. Do you mean A.0, B.0 or C.0? The internal numbering of the pins in PICAXE are numbered 0-7 for B.0 to B.7, 8-15 for C.0 to C.7 and 16 to 20 for A.0 to A.4. It is recommended to explicitly address the pin by 'port.pin' annotation Eg C.0
 

hippy

Technical Support
Staff member
The Serial IN/OUT pins of the 28X2 are jumpered to the gray cable from the PIXY CMUcam5

28X2 to PIXY
2 to 1
1 to 4
If you have an AXE200/AXE201 module and you mean legs 1 and 2 of that; those are the Download Serial In and Out connections.

If you can post a link to the PIXY CMUcam5 which details which pins do what; that will help others check that you are using the correct pins.

I have the PIXY CMUcam5 I/F setup for SPI with SS at 9600 8N1 Baud
I am not familiar with the device but SPI cannot be controlled with SERIN / SEROUT.
 

SolidWorksMagi

Senior Member
Hi,

IF I'm using PIN 2 of the 28X2 module I don't know the "C.x or A.x" designation. The PICAXE manual only calls it PIN 2.
 

hippy

Technical Support
Staff member
IF I'm using PIN 2 of the 28X2 module I don't know the "C.x or A.x" designation. The PICAXE manual only calls it PIN 2.
If you look in "PICAXE Manual 1 - Getting Started", on page 36, there is a pinout of the AXE200 and AXE201 module with port.pin designations against each pin/leg where appropriate.

Pins/legs 1 and 2 of those modules are used for the Download Interface so would not normally be used to connect to a serial device.

One of the pins/legs 5 through 24 should be selected for receiving data from your camera and then your program code needs to use the port.pin name shown in the manual.

For example, if you chose pin/leg 5 to receive data, that is C.0, you would then use SERIN C.0 in your code.
 

hippy

Technical Support
Staff member
This seems to be the best PIXY CMUcam5 info page for the device;
http://cmucam.org/projects/cmucam5/wiki/Porting_Guide
If you look down that to the "Setting the interface" it appears you should select "UART" for the "Data out port".

You will need to change your camera configuration to "UART" from "SPI with SS" to make it communicate serially with the PICAXE.

Until that is done, until the camera is appropriately connected to the PICAXE module, nothing will work, and you may potentially damage the camera module and/or PICAXE module.

It appears to me that -

Pin 10 (GND) of the camera should connect to the PICAXE 0V

Pin 4 (UART TX, output) of the camera should connect to the PICAXE pin used for SERIN

Pin 1 (UART RX, input) of the camera would connect to the PICAXE pin used for SEROUT

The way you currently describe it, it seems Pin 4 (UART TX) of the camera connects to pin 1 ( Download Serial Out ) of the PICAXE module which may cause damage if you change the camera configuration and try to use that same wiring.
 

SolidWorksMagi

Senior Member
Hi,

I woke up this morning thinking about just that ... changing to another I/O type on the PIXY.

I edited the program to this;

Do
; Sync ChkSum SigNum X Y Width Height
;SerIN 2,T9600_8,b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17
SerIN 2,T9600_8,w1

SerTXD ("PIXY say's; ",b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17)
pause 10

Loop

Still nothing in the #Terminal screen ??? I figured this should give me at least the first 8 Bytes with data, but the #Termainal IN screen stays blank.


BTW, I bring +5V and 0V (Gnd) to the gray cable too ... the PIXY CMUcam5 is powered by the 5V battery pack I'm using. I can see the PIXY CMUcam5 recognizing a moving colored object in front of the camera by the little LED on the PIXY CMUcam5.
 
Last edited:

SolidWorksMagi

Senior Member
Hi,

I changed the jumper to PIN 8 C.3 and now I get the message "PIXY say's; " over and over but still no data. But this is getting me closer to the final solution ...

Do
SerIN C.3,T9600_8,w1
pause 25

SerTXD ("PIXY say's; ",b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, cr, lf)
pause 1000

Loop
 

hippy

Technical Support
Staff member
This code may help ...

Code:
#Picaxe 28X2
#Terminal 9600

Symbol RX_PIN  = C.3
Symbol RX_BAUD = T9600

Do
  SerIn RX_PIN, RX_BAUD, ($AA), 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 )
Loop
That is derived from code in another thread recently discussing the CMUcam5 Pixy ...

http://www.picaxeforum.co.uk/showthread.php?26245-Camera-Pixy-vision-sensor
 

srnet

Senior Member
I'm a 3D CAD modeler not a professional programmer, or electronics engineer so much information posted for these things is not aimed at hobbyists that just want to make stuff.
They provide do sample code and what appears to be good instructions for some Microcontrollers, but not PICAXE.

Its not unusual (or unreasonable) when a manufacturer of a device provides interface documentation to assume a reasonable knowledge of electronics.
 

SolidWorksMagi

Senior Member
Hi,

Sorry about that 28X1 thing ... I've been switching between several webpage tabs back 'n forth trying to find the answers ... ITMT;

I woke up this morning thinking about just that ... changing to another I/O type on the PIXY.

I edited the program to this;

Do
; Sync ChkSum SigNum X Y Width Height
;SerIN 2,T9600_8,b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17
SerIN 2,T9600_8,w1

SerTXD ("PIXY say's; ",b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17)
pause 10

Loop

Still nothing in the #Terminal screen ??? I figured this should give me at least the first 8 Bytes with data, but the #Termainal IN screen stays blank.


BTW, I bring +5V and 0V (Gnd) to the gray cable too ... the PIXY CMUcam5 is powered by the 5V battery pack I'm using. I can see the PIXY CMUcam5 recognizing a moving colored object in front of the camera by the little LED on the PIXY CMUcam5.
 

hippy

Technical Support
Staff member
Sorry about that 28X1 thing ... I've been switching between several webpage tabs back 'n forth trying to find the answers ...
It's going to get quite tiring if the thread drifts off track or it appears help given is being ignored or overlooked. Not sure why you repeated what you have previously written. Did you read post #12 ?
 

SolidWorksMagi

Senior Member
Hi,

Just loaded that code in and it's working ... Thanks! I hadn't ReFreshed my browser tab on the last update I made ... hence hadn't seen the newer postings. Thanks again!
 

SolidWorksMagi

Senior Member
Hi,

Okay, I think this is the final post for me here;


The PIXYbot Sees My Colorful Balls


The program listing;
Code:
; 28X2+PIXYcam5-Serial.bas

; RoboGuts + PICAXE 28X2 module + SpeakJet chip + PIXY CMUcam5 + 3D Printed miniFloppyBot [URL]http://www.R2Pv1.com/[/URL] 

#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

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

init: servo RWheel,150
      servo LWheel,150

symbol i = b15
      
; BEGIN Main Body * * * * * * * * * * * * * * *
pause 1000
gosub red
pause 1000
gosub green
pause 1000
gosub blue
pause 1000
gosub Pink
pause 1000
gosub Orange
pause 1000
gosub Teal
pause 1000
gosub LEDsOFF

gosub Cntr
gosub Speech1

Do

SerIn RX_PIN, RX_BAUD, ($AA), 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
IF w2 = 260 then gosub YWarn
IF w2 = 261 then gosub PWarn
IF w2 = 262 then gosub OWarn
IF w2 = 263 then gosub PKWarn
;IF w2 = 264 then gosub Warn

;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 Teal
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 red
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 Blue
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 LEDsOFF
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
; 
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)
gosub Police
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
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
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
return

YWarn:
; I see yellow
; 
gosub Orange
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 187, 187, 128, 128, 128, 131, 146, 137)
pause 1000
return

PWarn:
; I see purple
; 
gosub blue
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 187, 187, 128, 128, 199, 7, 151, 199, 8, 146)
pause 1000
return

OWarn:
; I see orange
; 
gosub Orange
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 187, 187, 128, 128, 153, 141, 165)
pause 1000
return

PKWarn:
; I see pink
; 
gosub Pink
hserout 0,(20, 96, 21, 114, 22, 88, 23, 5, 157, 187, 187, 128, 128, 198, 7, 128, 143, 196)
pause 1000
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 2000
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

Police:
For i = 0 to 9
gosub red
pause 50
gosub LEDsOFF
gosub red
pause 50
gosub LEDsOFF
pause 100
gosub blue
pause 50
gosub LEDsOFF
gosub blue
pause 50
gosub LEDsOFF
pause 100
next i
return
; END RGB LED subroutines * * * * * * * * * * * * * * * *
end

That's about as good as color recognition gets using the PIXY CMUcam5 connected to a PICAXE.

Next is for people to create some games around this idea ...

This code along with all the .STL files and wiring diagrams will be posted on my website soon ... I hope! http://www.R2Pv1.com/

Final huge thanks again for the help I got here in the forums! This is the most useful and helpful forum I've found on the net!
 
Last edited by a moderator:

hippy

Technical Support
Staff member
Excellent work and thanks for letting us know it's working and seeing it in action.
 

SolidWorksMagi

Senior Member
This code may help ...

Code:
#Picaxe 28X2
#Terminal 9600

Symbol RX_PIN  = C.3
Symbol RX_BAUD = T9600

Do
  SerIn RX_PIN, RX_BAUD, ($AA), 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 )
Loop
That is derived from code in another thread recently discussing the CMUcam5 Pixy ...

http://www.picaxeforum.co.uk/showthread.php?26245-Camera-Pixy-vision-sensor

Hi,

How do I replace this code;

#Picaxe 28X2
#Terminal 9600

Symbol RX_PIN = C.3
Symbol RX_BAUD = T9600

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


with I2C to do the same thing?

I tried;

HI2cSetup I2CMASTER, 0xA8, I2Cslow, I2CBYTE ; A8 = PIXY CMUcam5
HI2cIn 0xA8,(b1, b3,b2, b5,b4, b7,b6, b9,b8, b11,b10, b13,b12)

But all I get is 0's ...
 
Last edited:

hippy

Technical Support
Staff member
How do I replace this code .... with I2C to do the same thing?
From what I can tell you need to poll for 16-bit data then determine when a new frame and/or a new object is being transmitted. Perhaps something like -
Code:
Do
  Do
    Do
      HI2cIn ( b1, b0 ) 
    Loop Until w0 = $AA55
    HI2cIn ( b1, b0 ) 
  Loop Until w0 = $AA55 Or w0 = $AA56
  HI2cIn ( b3,b2, b5,b4, b7,b6, b9,b8, b11,b10, b13,b12 )
  Select Case w0
    Case $AA55 : SerTxd( "Normal")
    Case $AA56 : SerTxd( "Color")
  End Select
  SerTxd( " Checksum="  , #w1 )
  SerTxd( " Signature=" , #w2 )
  SerTxd( " X="         , #w3 )
  SerTxd( " Y="         , #w4 )
  SerTxd( " Width="     , #w5 )
  SerTxd( " Height="    , #w6 )
  SerTxd( CR, LF )
Loop
That's from the limited information I can find here -

https://docs.pixycam.com/wiki/doku.php?id=wiki:v1:porting_guide

It may need to be more complicated than that because it looks like it needs to differentiate between start of frame and start of normal or colour object.

I would suggest sticking with UART serial as that is working and understood. There doesn't seem to be any gain from moving to I2C, only disadvantages, not least that you have to get that working, figure out how it works and why not if it doesn't.

It seems a classic case of "if it's not broken; don't fix it", but if you are determined to move to I2C I would start with -
Code:
Do
  Do
    HI2cIn (b1,b0 )
  Loop Until w0 <> $0000
  b11 = w0 / $1000 & $0F + "0" : If b11 > "9" Then : B11 = b11 + 7 : End If
  b12 = w0 / $100  & $0F + "0" : If b12 > "9" Then : B12 = b12 + 7 : End If
  b13 = w0 / $10   & $0F + "0" : If b13 > "9" Then : B13 = b13 + 7 : End If
  b14 = w0         & $0F + "0" : If b14 > "9" Then : B14 = b14 + 7 : End If
  SerTxd( "$", b11, b12, b13, b14, CR, LF )
Loop
 

SolidWorksMagi

Senior Member
From what I can tell you need to poll for 16-bit data then determine when a new frame and/or a new object is being transmitted. Perhaps something like -
Code:
Do
  Do
    Do
      HI2cIn ( b1, b0 )
    Loop Until w0 = $AA55
    HI2cIn ( b1, b0 )
  Loop Until w0 = $AA55 Or w0 = $AA56
  HI2cIn ( b3,b2, b5,b4, b7,b6, b9,b8, b11,b10, b13,b12 )
  Select Case w0
    Case $AA55 : SerTxd( "Normal")
    Case $AA56 : SerTxd( "Color")
  End Select
  SerTxd( " Checksum="  , #w1 )
  SerTxd( " Signature=" , #w2 )
  SerTxd( " X="         , #w3 )
  SerTxd( " Y="         , #w4 )
  SerTxd( " Width="     , #w5 )
  SerTxd( " Height="    , #w6 )
  SerTxd( CR, LF )
Loop
That's from the limited information I can find here -

https://docs.pixycam.com/wiki/doku.php?id=wiki:v1:porting_guide

It may need to be more complicated than that because it looks like it needs to differentiate between start of frame and start of normal or colour object.

I would suggest sticking with UART serial as that is working and understood. There doesn't seem to be any gain from moving to I2C, only disadvantages, not least that you have to get that working, figure out how it works and why not if it doesn't.

It seems a classic case of "if it's not broken; don't fix it", but if you are determined to move to I2C I would start with -
Code:
Do
  Do
    HI2cIn (b1,b0 )
  Loop Until w0 <> $0000
  b11 = w0 / $1000 & $0F + "0" : If b11 > "9" Then : B11 = b11 + 7 : End If
  b12 = w0 / $100  & $0F + "0" : If b12 > "9" Then : B12 = b12 + 7 : End If
  b13 = w0 / $10   & $0F + "0" : If b13 > "9" Then : B13 = b13 + 7 : End If
  b14 = w0         & $0F + "0" : If b14 > "9" Then : B14 = b14 + 7 : End If
  SerTxd( "$", b11, b12, b13, b14, CR, LF )
Loop

Hi,

Yeah, serial works, but I want to use I2C with a few devices including multiple cameras ...

I'm not getting anything back in the terminal window ... I do have 4.7KΩ pull-up resistors on both I2C lines C.3 and C.4

23613

23614
 

hippy

Technical Support
Staff member
You will need an HI2CSETUP command at the start of your code. With the camera having an I2C address of 0x54 that would be one of the following -

HI2cSetup I2CMASTER, $54, I2CSLOW, I2CBYTE
HI2cSetup I2CMASTER, $A8, I2CSLOW, I2CBYTE
 

hippy

Technical Support
Staff member
It's much easier to diagnose what's going on if you can post textual copies of the program and the Terminal output than images or videos.

Your -
Code:
 Do
    HI2cIn (b1,b0 )
    SerTxd( "$", b11, b12, b13, b14, CR, LF )
  Loop Until w0 <> $0000
Will always print "[00][00][00][00]" because b11-b14 are never set, remain at their initial zero values. That doesn't show what is being received into 'b1' and 'b0' but we know both are zero or the code would progress beyond the "Loop Until w0 <> $0000" line and it does not.

As to why it's receiving only zeroes I don't know. That is apparently a 'nothing seen' marker.

Given the I2C data is said to include 'end of frame' markers, It could be that the internal buffers are written 'live', as the frame is captured, and if you don't read them quickly enough they are lost. It could be that the PICAXE simply isn't quick enough to capture them.

Without any explanation of the I2C protocol everyone is flying blind. The manufacturer may have data explaining how their I2C implementation works, how to use it, and what the constraints are.
 

SolidWorksMagi

Senior Member
Hi,

Okay, no more videos. I made the video to show exactly what I was doing and getting. I actually ran that sequence a dozen or more times and just picked a short part to post.

I've not had problems sending data via I2C to OLED displays, but receiving I2C seems to be a problem from cameras so far. I have a CMUcam2, PIXY, a PIXY2 and a HuskyLens.
 

hippy

Technical Support
Staff member
I've not had problems sending data via I2C to OLED displays, but receiving I2C seems to be a problem from cameras so far.
For I2C to OLED displays and other devices we normally have a well defined and documented protocol, example code or enough information to be able to figure it out. Which makes that pretty easy.

For receiving from these cameras using I2C we have very little. Which means guessing and hoping it works.
 
Top