Sunspot
"Ratting a scanner"
Byvac BV4213 stepper motor driver used to convert a scanner into a linear camera mover
personal notes for my backup
Objective
Learn about stepper motors by using an old image scanner mechanism that was about to be tipped.
Drive by the existing 4 wire stepper motor to move a web camera attached to a glass-walled bee hive.
Attempt to make a close up time lapse film of bees building a queen cell (next year!)
The Byvac BV4213 has several drive modes.
I need a second i2c device to detect the end of transit of the stepped scan,
to detect the end of scan microswitch state, to drive the motor power, to drive the white LEDs that illuminate the bees
and to drive the Byvac directly- (I tried and failed to drive the Byvac via it's own i2c port)
- so I used an i2c to 8 wire PCF8574P
- the 8 pin chip is a long i2c line driver - a 82B715
Circuit
The stepper motor drives a carriage that holds a web camera.
Microswitches detect when the carriage is at the end of its allowed area.
Three white LEDs illuminate the bees, but only when the system is live.
The scanner flexible ribbon cable was used for all signals by cutting out the existing connections with Dremmel.
#!/usr/sbin/blassic full = VAL(PROGRAMARG$(1)) LABEL StartHere ' line 0 must be low for the motor to receive power via the P channel MOSFET byte_out_HI = 128 + full*64 +direction*32 + 16 byte_out_HI$ = STR$(byte_out_HI) PRINT byte_out_HI$, byte_out_LO$ FOR i=1 to steps ' switch line 4 HI and LO (motor steps on transition up or down) ' are we on the buffer? 'turn the LEDs and motor power off now the motor is not needed SYSTEM LABEL EndStop byte_out_HI = 128 + full*64 +direction*32 + 16 FOR i=1 to steps SHELL "PCF8574_addr_byteout 38 "+ byte_out_HI$ 'turn the LEDs and motor power off 'switch full dirn HI/LO 3 2 1 0-used for <Motor_Power (ON = 0)> ' note if the main power is turned on but no control is received |
/* 1) set the i2c address of the PCF8574 #include <stdio.h> int i2c; int main(int argc, char** argv) { printf("Error. usage: %s i2c_chip_address\n", argv[0]); } address = atoi(argv[1]); /* address is the first number after the program name */ i2c = open("/dev/i2c/0",O_RDWR); /* open the i2c-bus number 0 */ ioctl(i2c,I2C_SLAVE, address); /* set the address of the chip we will talk to */ buf[0] = 255; read(i2c,buf,1); /* now buf(0) contains the byte of data on the 8 port lines*/ byte = buf[0]; printf("%d", byte); i2c = close(i2c); |
/* 1) set the i2c address of the PCF8574 #include <stdio.h> int i2c; int main(int argc, char** argv) { address = atoi(argv[1]); /* address is the first number after the program name */ i2c = open("/dev/i2c/0",O_RDWR); /* open the i2c-bus number 0 */ ioctl(i2c,I2C_SLAVE, address); /* set the address of the chip we will talk to */ buf[0] = 255; read(i2c,buf,1); /* now buf(0) contains the byte of data on the 8 port lines*/ byte = buf[0]; printf("BYTE = %d \n", byte); i2c = close(i2c); |
Bee pictures to follow ?!?!
More here