<< return to Pixycam.com

User Tools

Site Tools


wiki:v2:porting_guide

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
wiki:v2:porting_guide [2018/07/05 23:09]
pixycam
wiki:v2:porting_guide [2019/02/01 15:39]
pixycam
Line 37: Line 37:
  
  
-{{wiki:v2:image_380.png}}+{{wiki:v1:image_743.png}}
  
  
Line 65: Line 65:
   - Data bits are latched on the falling edge of SPI SCK   - Data bits are latched on the falling edge of SPI SCK
   - Slave select is active low   - Slave select is active low
 +  - Uses SPI mode 3, as described on [[https://​www.corelis.com/​education/​tutorials/​spi-tutorial/​|this page]]
 +  - 3.3V outputs, 5V tolerant inputs
  
 Pixy2 also supports SPI with slave select (SPI with SS). Pixy2 also supports SPI with slave select (SPI with SS).
Line 162: Line 164:
  
  
-Communication with Pixy2 begins by sending a request packet. ​ For example, here is a packet to request the hardware ​and firmware ​versions.  (Normally, request packets are sent without using checksums.):​+Communication with Pixy2 begins by sending a request packet. ​ For example, here is a packet to request the hardware/firmware ​version data chunk.  (Normally, request packets are sent without using checksums.):​
  
  
Line 173: Line 175:
  
  
-Pixy2 will respond with the packet (or similar, depending on the hardware ​and firmware versions.) ​ Response packets always have checksums so the receiver (your controller) can test data integrity:+Pixy2 will respond with the packet ​bytes below (or similar, depending on the hardware/firmware versions.) ​ Response packets always have checksums so the receiver (your controller) can test data integrity:
  
  
Line 241: Line 243:
  
 If you can't get this request-response to work, spend some time trying to determine what might be going wrong. ​ Try using an oscilloscope to see if your controller is outputting data as expected (first), and Pixy2 is outputting data as expected in response (second). ​ The challenge with getting any communication interface up and running is the strict requirement that the wiring, connections,​ and code (everything) need to be correct in order for it to work.  If any single detail is not correct, e.g. missed/​swapped connection or incorrect initialization code, communication will not work (at all).  So we start with this simple exchange. ​ The good news is that once you get this working, the hard part is over, and the rest is quick/​easy.  ​ If you can't get this request-response to work, spend some time trying to determine what might be going wrong. ​ Try using an oscilloscope to see if your controller is outputting data as expected (first), and Pixy2 is outputting data as expected in response (second). ​ The challenge with getting any communication interface up and running is the strict requirement that the wiring, connections,​ and code (everything) need to be correct in order for it to work.  If any single detail is not correct, e.g. missed/​swapped connection or incorrect initialization code, communication will not work (at all).  So we start with this simple exchange. ​ The good news is that once you get this working, the hard part is over, and the rest is quick/​easy.  ​
 +
 +
  
  
 ==== TPixy2.h ==== ==== TPixy2.h ====
  
-[[https://​github.com/​charmedlabs/​pixy2/​blob/​master/​src/​host/​arduino/​libraries/​Pixy2/​TPixy2.h|TPixy2.h]] is a template class that can be easily reused, if your porting language is C/C++.  If your porting language isn'​t ​C/C++, it's still a good reference for the port translation,​ as it contains request-response code for all possible requests and responses. ​  ​[[https://​github.com/​charmedlabs/​pixy2/​blob/​master/​src/​host/​arduino/​libraries/​Pixy2/​Pixy2CCC.h|Pixy2CCC.h]] and [[https://​github.com/​charmedlabs/​pixy2/​blob/​master/​src/​host/​arduino/​libraries/​Pixy2/​Pixy2Line.h|Pixy2Line.h]] are also needed to round out the [[wiki:​v2:​full_API|Pixy2 API]]. ​   +[[https://​github.com/​charmedlabs/​pixy2/​blob/​master/​src/​host/​arduino/​libraries/​Pixy2/​TPixy2.h|TPixy2.h]] is a template class that can be easily reused, if your porting language is C++.  If your porting language isn't C++, it's still a good reference for the port translation,​ as it contains request-response code for all possible requests and responses. ​  ​[[https://​github.com/​charmedlabs/​pixy2/​blob/​master/​src/​host/​arduino/​libraries/​Pixy2/​Pixy2CCC.h|Pixy2CCC.h]] and [[https://​github.com/​charmedlabs/​pixy2/​blob/​master/​src/​host/​arduino/​libraries/​Pixy2/​Pixy2Line.h|Pixy2Line.h]] are also needed to round out the [[wiki:​v2:​full_API|Pixy2 API]]. ​  ​
  
  
-TPixy2.h uses the LinkType class to communicate with Pixy2. ​ It assumes some member functions and an implementation of millis() and delayMicroseconds(),​ as shown in the header code below:+We have a complete protocol reference below. ​ It will be very helpful if you are porting to a platform in a language other than C++.  But if you are using C/​C++, ​TPixy2.h ​is a good starting point. ​ It uses the LinkType class to communicate with Pixy2. ​ It assumes some member functions and an implementation of millis() and delayMicroseconds(),​ as shown in the header code below:
  
 <​code>​ <​code>​
Line 311: Line 315:
 When attempting to get your link class integrated and everything working, problems may arise and you may have to track down the problem. ​ A good place to start is in the getSync() function in TPixy2.h of the code.  Is it finding the sync codes from Pixy2? ​ If not, why?  Is it getting the correct bytes? ​ If it is successfully getting the sync codes, there is a problem occuring after getting the sync.  This will get you started. :-) When attempting to get your link class integrated and everything working, problems may arise and you may have to track down the problem. ​ A good place to start is in the getSync() function in TPixy2.h of the code.  Is it finding the sync codes from Pixy2? ​ If not, why?  Is it getting the correct bytes? ​ If it is successfully getting the sync codes, there is a problem occuring after getting the sync.  This will get you started. :-)
  
-If you need help, post on our [[https://​forum.pixycam.com/​|forum]] or send us an email (support@charmedlabs.com). ​ Happy coding!+If you need help, post on our [[https://​forum.pixycam.com/​|forum]] or send us an email (support@pixycam.com). ​ Happy coding! 
  
 +{{page>​wiki:​v2:​protocol_reference&​noindent}}
  
  
  
wiki/v2/porting_guide.txt · Last modified: 2020/04/27 19:08 by jfrench