-
According to your phase sequence, you are running in full steps, that is, each step is a cycle, 4 steps and a cycle, that is, 50 cycles per revolution. So the 512 in your program is not right to make one turn, and the 512 will turn more than 10 times.
According to your program, J will stop when it reaches zero, and there is no such thing as going on all the time.
If you want to stop at any time, you can add a button to switch the start and stop.
main()
unsigned char i,flag;
unsigned int j;
j=512*2;512 turns.
p0=0xff;Turn off the bit selection signal of the digital tube. Prevent the digital tube from being affected by the signal of the P0 port.
delay(500);
wela=1;wela=p2 7, enable bit selection, write in command.
delay(500);
wela=0;
flag=0;
while(1)
for(i=0;i<4;i++) 4 phases.
p0=b_rotation[i];The corresponding phase of the output can be reversed**.
while(1)
if(key==0)
while(key==0);Wait for the key to be raised.
flag=~flag;
if(flag)break;
delay(400);Changing this parameter can adjust the motor speed, the smaller the number, the greater the speed.
-
Each time the loop function completes, it returns to the main function, and then calls the stop function in the main function.
-
With drive, as long as the microcontroller outputs the direction level and the pulse of the step, the stepper motor can follow yours.
The meaning was reversed.
Infrared control, if you refer to the remote control, you have to use the infrared integrated tube to decode the received code.
Then, according to the analyzed value, the forward and reverse control stepper motor is carried out.
If it is an infrared beaming tube, it is simpler, that is, the switching amount is input to the IO of the single-chip microcomputer, and the stepper motor is controlled according to the level or different IO input.
-
There is mainly a voltage conversion chip 7805
-
The four-phase blocking and five-wire stepper motor adopts a unipolar control method in the control method and wiring side, which can be driven by 2003, and the single-chip microcomputer provides the role of a ring distributor.
-
That thing is much more complicated than a single-chip microcomputer.,Scrambled eggs,,Can't send a link.。
-
To control four stepper motors, you need four ULN2003A, include
unsigned char code f_rotation[4]=;Forward Rotation**.
unsigned char code b_rotation[4]=;Rollback**.
void delay(unsigned int i) delay main()}
This is the program of a single stepper motor, control four, change the "P1" in each of them!
-
Of course, if the ABCD sequential power-up control is forward, the ADCB sequential power-on is reversed. This is how any stepper motor controls forward and reverse rotation.
-
Forward and reverse reversal can be realized, as long as the assignment part of the program is written backwards, it is OK, for example, take a single beat forward rotation as an example:
p0=0x01;delay();//0001p0=0x02;delay();//0010p0=0x04;delay();//0100p0=0x08;delay();1000 then the reversal is:
p0=0x08;delay();
p0=0x04;delay();
p0=0x02;delay();
p0=0x01;delay();
If you want to increase the driving torque, you can supply two lines of power at the same time, and the forward rotation assignment is as follows (you should be able to understand it):
0x03;//0011
0x06;//0110
0xc0;//1100
0x09;//1001
The second problem, yes, the program can be slightly modified, to 4 lines, of course, the program can not move at all can also let him spin, but the speed is unstable.
-
It is impossible to use a single-chip microcomputer at the same time, of course, the time interval is small enough to be acceptable, and running several tasks can also be regarded as simultaneous. To achieve true simultaneity, it is possible to do it with FPGA CPLD.
Having said that, maybe your simultaneous operation does not mean that it must be strictly working at the same time, but that a single-chip microcomputer can control four stepper motors, and it will be much easier.
A stepper motor, such as a 4-phase 5-wire one, can control one of the 4 IO ports, 16 of the four stepper motors, and ULN2003 can be used for the driver chip.
Of course, if your IO port is not allowed to use so much, you can also expand the IO port by serial and merging methods, such as using 74HC595, three IO ports to control it, it can be cascaded, and three wires can control many pieces. One is 8 bits, two are 16 bits, and 3 are 24 bits ......As long as you add some transistors to drive the three control lines, the three IO ports can control a series of cascaded 74HC595, and the expansion IO ports obtained are quite a lot. I have used three IO ports to control 5 pieces of 74HC595, and the three IO ports have been expanded to 40 IO ports at once!!
-
You can use 51 single-chip microcomputer and a special motion control chip, such as HMC8045, 51 single-chip microcomputer sends a four-way synchronous control instruction to the special chip, and the special chip controls the motor synchronization, and the single-chip microcomputer only needs to wait for the movement in place and then send the next instruction.
-
51 to do, difficult, the effect is not good, take it to learn single-chip microcomputer programming, practical engineering application is almost impossible. Engineering applications can choose the serial port four-axis motion controller, the single-chip microcomputer sends serial port instructions to the controller, to achieve continuous operation, positioning operation, back to zero, etc., very easy.
-
In general, the so-called simultaneous does not exist, and the definition of real-time in embedded should be that the main frequency is relatively high (high enough frequency), the tasks are executed one by one, so that the time difference between each task is very small (the above is a personal opinion, not a public opinion). The stepper motor generally needs to add an external motor drive circuit, and then use the IO control of the single-chip microcomputer (the high-power stepper motor can be controlled with L297+L298, and the low-power with ULN2008 ULN2003 should be fine.) The 51 microcontroller has 32 IO ports that can be used, and there is no problem in driving 4 stepper motors.
Scheduled interrupts, external interrupts?
Wiring indications. A (orange), B (yellow), C (blue), D (gray), E (red, midpoint. >>>More
< symbol indicates a left shift, and the highest digit enters the carry symbol C, which is the CY used below >>>More
The requirements you describe are not very clear, they should be described step by step, and the requirements for each step are written out step by step, so that everyone can easily understand. >>>More
If the timer count value is not enough, you can first set the sum number of 1, such as 1ms, and then add another number to 10 to 100ms to get the 1s time.