This post has NOT been accepted by the mailing list yet.
Hi everyone.
I am currently working on a project where I am using the Dragon12 microcontroller to hook up a Stepper Motor and a Solenoid. I have the stepper motor currently hooked up already and I have some primitive code to run the Motor in one direction (only), continuous run. I am using the pins M1-4. The solenoid is not connected yet. My original idea: I want to send a signal, whether it is a switch or incoming data, to activate the solenoid on the board (which will be unlocking a cabinet), and then right at that instant move the stepper motor to open and move forward the cabinet for about 30 seconds to a minute, wait, then retract the cabinet back to its original closed position (with the same amount of turns). I have already purchased gears and I am still waiting for the right rail to work with the gear. I also am not sure where I should hook up the solenoid to? One of my friends was mentioning a Relay, but he has a strong language and all he is saying "Don't forget the relay". Now I was wondering if you guys could help me try to figure this out. Here is the code I am using: #include <hidef.h> /* common defines and macros */ #include "derivative.h" /* derivative-specific definitions */ void MSDelay(unsigned int); void main(void) { /* put your own code here */ DDRB = 0x0F; //PORTB0-PORTB3 as output DDRP = 0x03; //PORTP0 and PORTP1 as output for 12EN=1 and 34EN=1 ```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` PORTB=0b00000000; // start with all off PTP=0b00000011; //Turn on both 12EN and 34EN Enables for 754410 chip for() { PORTB=0b00000011; MSDelay(50); PORTB=0b00000110; MSDelay(50); PORTB=0b00001100; MSDelay(50); PORTB=0b00001001; MSDelay(50); for() { PORTB=0b00000011; MSDelay(50); PORTB=0b00001001; MSDelay(50); PORTB=0b00001100; MSDelay(50); PORTB=0b00000110; MSDelay(50); } } } //millisecond delay for XTAL=8MHz, PLL=48MHz //The HCS12 Serial Monitor is used to download and the program. //Serial Monitor uses PLL=48MHz void MSDelay(unsigned int itime) { unsigned int i; unsigned int j; for(i=0;i<itime;i++) for(j=0;j<4000;j++); //1 msec. tested using Scope } |
This post has NOT been accepted by the mailing list yet.
Please help!!
|
Free forum by Nabble | Edit this page |