mirror of project files can be found at GitHub - zemerdon/autozem: autozem
Software used :-
Arduino IDE
Python 3.10 ( install pyserial )
HWiNFO
Hardware used :-
Arduino UNO R3
Screw Shield Terminal Expansion Board for Arduino Uno Board
StarTech USB A to USB 4 Pin Header Cable
Blue USB A to B cable
Sullivan Servo Horn
2mm Threaded Rod
Readytosky 12kg Servo 180 Degree High Torque Full Metal Gear Low Profile Digital Servo
Power Supply - Multi-voltage 4A Power Adapter with 7 interchangeable DC Plugs
DC 5521 to 5525 Coupling
DC Power Extension Cable 1.5m length with 2.1mm plug and 2.5mm socket
Various 22 AWG Wire
Various Heat Shrink
Various JST housing, male and female connectors.
. : Software setup : .
Download, install Arduino IDE.
Install the following library…
http://www.glassier.biz/autozem/VarSpeedServo-master.zip
Upload sketch.
// 5-2-2022 added serial print
// 27-01-2022 project 'autozem'
// servos controlled - e.g 'L50' (move left servo 50º) and/or 'R50' (move right servo 50º). Arduino will accept upper and lower case.
// servos move at the same speed. (this can be changed at the bottom of the sketch)
// servos move independent of eachother thanks to varspeedservo.h interrupt method
// servos dont move to default location after board reset thanks to saving last entered serial angle in EEPROM and loading before servo is attached.
// ** Arduino UNO R3 board has auto-reset disabled ** (need to add switch for easier sketch uploading)
// use with HWiNFO
#include <EEPROM.h>
#include <VarSpeedServo.h>
int eeaddr1 = 0; //sets EEPROM address to use for storing servo1 last angle
int eeaddr2 = 10; //sets EEPROM address to use for storing servo2 last angle
char buffer[11];
VarSpeedServo servo1; //create a servo object
VarSpeedServo servo2; //create a second servo object
void setup()
{
servo1.write(EEPROM.read(eeaddr1)); //sets servo1 last angle before attaching so no erratic movement
servo2.write(EEPROM.read(eeaddr2)); //sets servo2 last angle before attaching so no erratic movement
servo1.attach(9); //attaches servo1 on pin 9 to the servo1 object
servo2.attach(10); //attaches servo2 on pin 10 to the servo2 object
Serial.begin(115200);
while (Serial.available())
Serial.read();
}
void loop() {
if (Serial.available() > 0) { // Check if data has been entered
int index = 0;
delay(100); //let the buffer fill up
int numChar = Serial.available(); // Find the string length
if (numChar > 10) {
numChar = 10;
}
while (numChar--) {
//fill the buffer with the string
buffer[index++] = Serial.read();
}
buffer[index] = '\0';
splitString(buffer); //run splitString function
}
}
void splitString(char* data) {
char* parameter;
parameter = strtok (data, " ,"); //String to token
while (parameter != NULL) { // If we haven't reached the end of the string...
setServo(parameter); // ...run the setServo function
parameter = strtok (NULL, " ,");
}
while (Serial.available())
Serial.read();
}
void setServo(char* data) {
int SPEED1 = 5; //servo1 speed. lower is slower
int SPEED2 = 5; //servo2 speed. lower is slower
if ((data[0] == 'L') || (data[0] == 'l')) {
int firstVal = strtol(data + 1, NULL, 10); // String to long integer
firstVal = constrain(firstVal, 1, 179); // Constrain values
servo1.write(firstVal, SPEED1);
EEPROM.update(0, firstVal); //save last entered serial angle for servo1 to EEPROM
Serial.print("Rear Servo is set to: ");
Serial.println(firstVal);
}
if ((data[0] == 'R') || (data[0] == 'r')) {
int secondVal = strtol(data + 1, NULL, 10); // String to long integer
secondVal = constrain(secondVal, 1, 179); // Constrain the values
servo2.write(secondVal, SPEED2);
EEPROM.update(10, secondVal); //save last entered serial angle for servo2 to EEPROM
Serial.print("Front Servo is set to: ");
Serial.println(secondVal);
}
}
Download, install Python 3.10.
https://www.python.org/downloads/release/python-3101/
Open command prompt and install pyserial for python.
c:\pip install pyserial
Download, install HWiNFO.
https://www.hwinfo.com/download/
Open regedit and navigate to the following key…
“Computer\HKEY_CURRENT_USER\SOFTWARE\HWiNFO64\Sensors”
create two new keys Custom and Custom so you now have…
“Computer\HKEY_CURRENT_USER\SOFTWARE\HWiNFO64\Sensors\Custom\Custom”
Create the following keys…
Computer\HKEY_CURRENT_USER\SOFTWARE\HWiNFO64\Sensors\Custom\Custom\Usage1
Computer\HKEY_CURRENT_USER\SOFTWARE\HWiNFO64\Sensors\Custom\Custom\Usage2
Computer\HKEY_CURRENT_USER\SOFTWARE\HWiNFO64\Sensors\Custom\Custom\Usage3
Computer\HKEY_CURRENT_USER\SOFTWARE\HWiNFO64\Sensors\Custom\Custom\Usage4
Under each key (Usage1, etc) create the following strings under each key, changing the name respectively…
new string → name = Name, data = whateveryouwanttocallit
new string → name = Value, data = “Physical Memory Used” (include quotations)
In HWiNFO it will look like this… ( i have renamed mine so yours will say RAM1 etc… )
Now we can setup the alert settings in HWiNFO…
Download the following files…
( mine are placed under c:\autozem\ )
( the .BAT files are linked to the python files and at time of writing this HWiNFO only accepted .EXE or .BAT files for running a program on alert. The next version of HWiNFO will accept any file so the batch files can be removed )
( .pyw was used as this runs the script as a background process with no pop-up window upon execution )
http://www.glassier.biz/autozem/front_close.bat
http://www.glassier.biz/autozem/front_close.bat
http://www.glassier.biz/autozem/front_open.bat
http://www.glassier.biz/autozem/rear_open.bat
http://www.glassier.biz/autozem/rear_close.bat
http://www.glassier.biz/autozem/front_close.pyw
http://www.glassier.biz/autozem/front_open.pyw
http://www.glassier.biz/autozem/rear_open.pyw
http://www.glassier.biz/autozem/rear_close.pyw
Right click your first custom sensor and head to Alert Settings…
So for my basic operation and diagnostics i set the following…
front close > 7900
front open > 8000
rear open > 8500
rear close > 8400
This way i could load RAM and unload RAM according to my needs. The fundamentals are the same if you decide to use a different sensor. You may need to play around with ‘notification distance’ and ‘trigger only once’ sections to get it working how you want.
. : NOTES : .
- let silicone cure for 72hours.
- use arduino monitor to find perfect angles then edit .pyw files to suit your needs.
- connect pushrod to servo ONLY when you know everything works fine else you run the risk of sheering the servo horn from the surface. If the stored angle is different from the current servo angle upon powering up, the servo will move at full speed.