These two servos is controlled by the servo controller using FPGA (Field programmable gate array). The video shows Panning operation and speed movement with deceleration stop. The part that is held down by hand is the usual servo control (FPGA servo controller function is OFF).
This article introduces the FPGA servo controller.
[Background]In my last report, I created an FPGA board for beginners. Now, let's apply it to the Arduino Nano 33 BLE OV7670 Camera Shield that I created earlier.
So far, I have tried to make something more fun by linking robotics and sensors. Some of the problems I often face are:
- Each element works correctly, but when combined, it does not.
- It is easy to specify the angle of the servo motor, but if another servo motor is attached to the servo as a load, it will be jerky and smooth operation will be difficult.
- It is not easy to execute processing such as sensors and cameras at the same time as controlling the servo motor.
- As the elements to be processed are piled up, the software becomes complicated and the resources used by various libraries start to compete.
Let's focus on servo motor control.
A.This is the simplest control example.
if(millis() - itime > 1000) { itime = millis(); tgl = !tgl;
pos = 135; if(tgl) pos = 45; myservo.write(pos); // Make servo go to xx degrees
}
After setting the servo, it will be released until the next setting, so you can do various work until the next setting.
However, the speed of movement depends on the servo, so if you have a actuator attached to the servo horn, it will flutter and it's unclear if the servo gear won't crack until the third day of your Maker Fare session.
B.There is a method called Sweep in the samekindofsample code of Arduino, so you can use it to control the speed of servo operation.
if(millis() - itime > 15) { itime = millis();
if(tgl) { pos++; if(pos >= 135) tgl = 0; }
else { pos—-; if(pos <= 45) tgl = 1; }
myservo.write(pos); // pos = …45.46.47.……135.134……
}
This allows gentle control. Even heavy loads can be handled by operating slowly. Acceleration and deceleration may be possible if an interval timer value table is prepared in memory.
However, since it is called every 15ms, the micro controller may need to abandon another job during servo control or perform sequence control in small chunks.
[About FPGA Servo Controller]In this project, MACHXO2-1200 is implemented instead of the previous PCA9685. In addition, a small 5-pin connector is also added for writing circuit data to the FPGA.
The angle of the servo motor is determined by changing the pulse width of the control signal from 0.5ms to 2.5ms.
- The FPGA Servo Controller consists of a 10-bit Current Position Register that determines the pulse width for control, an 8-bit Destination Register that specifies the target angle, and a Wait Timer Register that determines the speed when the servo moves.
- The command from the Micro controller issues 5 bytes of data, command code 0x01 and the specified angles of each of the four servos to the FPGA via UART.
- When Target Register is set via Command, Current Position Register is counted up or down until the upper 8 bits of Current Register are the same. The speed of the up or down pulse is specified by Wait Timer Register.
- By changing the value of Wait Timer Reg according to the distance between Current Reg and Target Reg during movement, soft landing operation can be performed after high-speed movement.
- When the Current Position Register and Target Register match, char 'C' is sent to the micro controller via the UART.
- The main program may find a completion notification by going to the UART register when it's free after issuing a move command to the servo and working busy for another process.
// 5byte UART Command
void Smove(byte angl0, byte angl1, byte angl2, byte angl3) {
svoComp = 0; // reset
dt[1] = angl0; dt[2] = angl1; dt[3] = angl2; dt[4] = angl3;
dt[0] = 0x01; mySerial.write(dt, 5); //
}
// When 0xff is specified for the angle, the corresponding servo is not affected. It can be operated at individual timing for each servo.
// Receive Servo Complete massage
if(mySerial.available() > 0)
{ if(mySerial.read() == 0x43); svoComp = 1; }
//
// 0x02:SERVO PARAMETERs, i.e. stop command:A specific servo can be stopped (Destination reg <= Current reg).
By using the FPGA servo controller, fine servo control can be expected even with less intervention on the processor.
In the next report, I would like to report an example of a four-legged robot.
Comments