Hello all, I could use some help from those more experienced with the design of μC code. I am working on a project in which I want to control 91 individual stepper motors using the Arduino Mega. Before you just write me off as crazy, I'll give you a description of the system.
The system is 81 linear actuators in a 9x9 array. The linear actuators are actuated using the stepper motors on a gear box assembly. You can think of it as a digital "Pin Art" toy. We are using a Microsoft Kinect to collect 3D data which will be downsampled to 9x9 and scaled according to our depth transfer function. Each linear actuator has a range of 8 cm with a step range of 127 steps (~0.62 mm/step). The 3D data is going to be scaled to this 7-bit value. The idea here is the "display" made of the linear actuators is going to be reproducing a 3D relief of whatever is in the Kinects defined imaging region. The 91 individual points are to be processed on a computer and transmitted via USB to the Arduino Mega, where the motion planning will be going on. The sample rate is going to be 10Hz. I've attached a block diagram of the system.
The stepper motors are 20 step/rev bipolars rated for 5v. Each will be pulling about 300mA when being operated at 4V. They're small chinese motors, 15mm diameter. They're going to be operated on full steps cycles, (ie no half steps).
9 identical PCBs are going to be fabricated, each containing 9 stepper motor drivers (PN MPC17C724EP from Mouser: http://www.mouser.com/ProductDetail/Freescale-Semiconductor/MPC17C724EP/?qs=r8OyiFxb6RdTneKUVVqNtTwvmFri%252bkC%252bgfRTjo7CasU%3d).
I'm using shift registers to control the stepper motor drivers, 74HC595s. 5 pins to control each driver (4 for the coils, 1 for power save mode), meaning 6 shift registers will be used on each PCB. Since I want a max step rate of 127 steps/second and want to have a step rate frequency resolution of about +/- 2 steps/sec, I figured out that the shift registers need to be refreshed at about 14kHz.
I'm hoping to use the software serial output of the Mega to have 9 parallel outputs, one for each of the control boards with the 9 stepper drivers and 6 shift registers. The shift registers use a 3 pin interface: CLK, DATA, and EN. I was figuring all board will use a common clk and enable and have unique data inputs. I need to write the 45 bits (5 bits/motor * 9 motors) to the shift register chains of each PCB then shift it to the parallel outputs of the shift registers in 14kHz cycles.
I am still working out the actual motion planning calculations and am unsure what my limits are going to be here with the microcontroller. I will be processing 81 7-bit values 10 times a second to generate an output step frequency for the stepper motors. I think I should be able to get away with performing some simple difference calculations between the current position value and the next position value. I am thinking I will buffer 2 or 3 samples to be taken into account with the motion planning for some sort of a 'look ahead' feature. Might be useful to make smoother acceleration and deceleration plans. I'm not trying to use serious motion planning algorithms because theyre not required, and it's OK if the acceleration and deceleration movements are more approximate than exact.
I think this covers the general plan I have right now. I have some experience with microcontrollers but this project is definitely more complicated than anything I have programmed before. I could really use some advice from those more experienced, even if the plan I have right now isn't likely to work, knowing that will help me get closer to something that does work. As I start to put the code together, hopefully I can get some help building it into a clean and compartmentalized code. Thanks for taking the time to give this a read!
The system is 81 linear actuators in a 9x9 array. The linear actuators are actuated using the stepper motors on a gear box assembly. You can think of it as a digital "Pin Art" toy. We are using a Microsoft Kinect to collect 3D data which will be downsampled to 9x9 and scaled according to our depth transfer function. Each linear actuator has a range of 8 cm with a step range of 127 steps (~0.62 mm/step). The 3D data is going to be scaled to this 7-bit value. The idea here is the "display" made of the linear actuators is going to be reproducing a 3D relief of whatever is in the Kinects defined imaging region. The 91 individual points are to be processed on a computer and transmitted via USB to the Arduino Mega, where the motion planning will be going on. The sample rate is going to be 10Hz. I've attached a block diagram of the system.
The stepper motors are 20 step/rev bipolars rated for 5v. Each will be pulling about 300mA when being operated at 4V. They're small chinese motors, 15mm diameter. They're going to be operated on full steps cycles, (ie no half steps).
9 identical PCBs are going to be fabricated, each containing 9 stepper motor drivers (PN MPC17C724EP from Mouser: http://www.mouser.com/ProductDetail/Freescale-Semiconductor/MPC17C724EP/?qs=r8OyiFxb6RdTneKUVVqNtTwvmFri%252bkC%252bgfRTjo7CasU%3d).
I'm using shift registers to control the stepper motor drivers, 74HC595s. 5 pins to control each driver (4 for the coils, 1 for power save mode), meaning 6 shift registers will be used on each PCB. Since I want a max step rate of 127 steps/second and want to have a step rate frequency resolution of about +/- 2 steps/sec, I figured out that the shift registers need to be refreshed at about 14kHz.
I'm hoping to use the software serial output of the Mega to have 9 parallel outputs, one for each of the control boards with the 9 stepper drivers and 6 shift registers. The shift registers use a 3 pin interface: CLK, DATA, and EN. I was figuring all board will use a common clk and enable and have unique data inputs. I need to write the 45 bits (5 bits/motor * 9 motors) to the shift register chains of each PCB then shift it to the parallel outputs of the shift registers in 14kHz cycles.
I am still working out the actual motion planning calculations and am unsure what my limits are going to be here with the microcontroller. I will be processing 81 7-bit values 10 times a second to generate an output step frequency for the stepper motors. I think I should be able to get away with performing some simple difference calculations between the current position value and the next position value. I am thinking I will buffer 2 or 3 samples to be taken into account with the motion planning for some sort of a 'look ahead' feature. Might be useful to make smoother acceleration and deceleration plans. I'm not trying to use serious motion planning algorithms because theyre not required, and it's OK if the acceleration and deceleration movements are more approximate than exact.
I think this covers the general plan I have right now. I have some experience with microcontrollers but this project is definitely more complicated than anything I have programmed before. I could really use some advice from those more experienced, even if the plan I have right now isn't likely to work, knowing that will help me get closer to something that does work. As I start to put the code together, hopefully I can get some help building it into a clean and compartmentalized code. Thanks for taking the time to give this a read!
Attachments
-
64.3 KB Views: 268