Embedded Eye

Give your gizmo the gift of sight


I'm putting a Stonyman Vision Chip on a Arduino Leonardo. May I know is the right way to pulse each digital pin?



I had also tried the 'First App' from this website https://github.com/ArduEye/ArduEyeExamples/tree/master/FirstApp_Sto...

but all I get is just white and black horizontal lines.

Thank you in advance for the help.

Views: 723

Reply to This

Replies to This Discussion

I've never used a Leonardo before so I am guessing the problem is due to the mapping between the Arduino "digital pins" (e.g. D4 through D8) and the ports on the Atmel processor. For example, D8, which connects to RESP in the library, is Port PB0 on an Arduino Uno (which uses ATmega328) but is port PB4 on the Leonardo (which uses an ATmega32u4).

The ArduEye_SMH library is written with the following correspondence: RESP=D8, INCP=D7, RESV=D6, INCV=D5, and INPHI=D4. The datasheet for the Stonyman chip describes these signals in greater detail.

Here is what I would do: (Note I don't have a Leonardo so I don't know if this will work but you should get the idea)

1) During setup use pinMode to set D4 through D8 as "outputs". I don't know if you need to do anything special for D8 since it appears to be a versatile pin.

2) rewrite these macros in ArduEye_SMH.h as follows:

#define SMH1_ResP_Pulse {digitalWrite(8,HIGH);digitalWrite(8,LOW);}

#define SMH1_IncP_Pulse {digitalWrite(7,HIGH);digitalWrite(7,LOW);}

#define SMH1_ResV_Pulse {digitalWrite(6,HIGH);digitalWrite(6,LOW);}

#define SMH1_IncV_Pulse {digitalWrite(5,HIGH);digitalWrite(5,LOW);}

If you are going to use the amplifier you will need to do something similar to the SMH1_InPhi_SetHigh and Low macros.

If you are not using a Rocket shield you can always use a different set of pins, say D7 through D3 or whatever works for you.

Let me know if this makes sense and if this works.

The reason you are seeing lines is because when the chip is not turned on or configured correctly, one of the circuits acts like a tiny solar cell and generates a small amount of electricity which you see on the display due to the 120Hz (or 100Hz if in Europe) AC lighting.


PS. I don't know why the last #define above is displayed to the right. It should be displayed the same.

Thank you for the reply. 

I modified the values as how Clinton McKinnon did (Thanks!!!!) but the result is still the same. I then tried using the simplest code to check if the the Stonyman vision chip is working properly. The code is as below:

void setup(){


for(int i=0; i<13; i++){

for(int i=0; i<13;i++){

digitalWrite(2,HIGH); //pulse RP to reset pointer

digitalWrite(7,HIGH); //pulse RV to reset COL value

for(int i=0; i<56; i++){ //pulse IV 56 times

digitalWrite(4,HIGH); //pulse IP to ROWSEL

digitalWrite(7,HIGH); //pulse RV to reset ROW value

for(int i=0; i<56; i++){ //pulse IV 56 times

void loop(){

The output that is get is around 350 to 360. When I flash a light source to it (1 to 2 cm from the lens) the value drops to 2 figures. Does this mean that there is nothing wrong with the code? 

But when the OE on the Stonyman vision chip is not connected to anything, this is what i get.

Thank you.

The code snippet you wrote above just accesses one pixel and writes it over and over. The values you are getting (from mid 300's regularly and lower values with light) would be reasonable, but it appears you didn't initialize the biases (NBIAS and AOBIAS) or the configuration register.

In the Arduino setup() function, you should also execute two initialization functions, specifically these:



Alternatively, you can just set these other registers to the following values. You only need to do this just once, in the setup() function:

VSW and HSW to 0. (Registers 2 and 3)

VREF, NBIAS, and AOBIAS to 55. (Registers 4, 6, and 7)

CONFIG to 16, assuming you are using raw mode. CONFIG is register 5.

This was our rework using a Teensy 2++ which is another usb type chip(1286) .  The zip file should have the pin defs and an example and the .h mod.  Note the Teensy's are small modules and do not follow the arduino pin out overouts.  If you compare the orginial files and the schematics it should make sense


Thank You Clinton.

By chance we have a teensy 2 which is a 32U4 rewrote the SMH.h and cpp file to not need a pin header works on both teensy2 & 2++ so should work for the leonardo, being the 32U4 and it follows Geof's described pinouts using digitalwrite


Thank you very much for the replies (Clinton & Geoffrey)!!!! It finally works!!!!! :D

Settings that I used:

cols = 24

row = 24

start col = 4

start row = 4

amp gain = 7

hor binning = 4

vert binning = 4

VREF = 5

NBIAS = 55

FPN mask = covering the camera with black surface

You're getting there! Are you using the amplifier? If so, I recommend turning it off- raw mode is adequate for most uses and is faster, simpler, and provides the highest dynamic range.

Also for calibration, try instead aiming the sensor at a uniform white (or other color) surface, such as an illuminated (ambient light OK) white sheet of paper or holding it right up to the computer screen on an even area. It is best for the calibration mask to be computed with similar intensity as that which you will utlimately use.

PS. Just for you, we updated the Stonyman data sheet to have some code examples (in pseudocode)! :)

The examples in the data sheet are really helpful!!! Thanks :D

I turned off the amplifier and calibrated with a piece of white paper. Lets say that I am using it to detect a light source. eg. when a light source is detected, a LED on the arduino board will turn on. But, without the amplifier being turned on, the red dot doesn't seem to move to the pixel where the light source is. In this case, should I turn on the amplifier?


How bright is the light compared to the background? Also, is the light the brightest thing in the environment?

In general you shouldn't need the amplifier. (In fact, I somewhat regret putting it in the chip because it confuses people...)


© 2022   Created by Geoffrey L. Barrows.   Powered by

Badges  |  Report an Issue  |  Terms of Service