Hi All to Introduce myself. I am qualified as an electrician, mechanical fitter and electronics. I am currently an Electrical Trainer Assessor. I love working on electronics and coding.
My current project is - I am building my second Electro Steel Guitar. I completed my first some 2 years ago and decided to upgrade to a even more modern design. My first I'm using servo motors to pull the strings, but because it is a little noisy I decided to try different pullers(steppers, dc motors).
Wish-list of the build include the following:
1. Body to be stainless plate. done
2. Led's on the fret bars that change color depends on the cord selected on the touch screen. done
3. Touch display. done
4. Manual tuning via touch display. done but changing the concept slightly by using different motor controllers.
5. Auto tuning, when selected - will adjust all 12 strings without touching the strings. Tested and working on single string but to be tested on all 12 strings. Code in progress. This concept will be the first ever to do this.
6. All esp32's are communicating through espnow. From the pedals to top espnow. done. I used a mix of Arduino and esp32 but could not get communication to run so I am now using a total of 6 esp32 modules.
7. Pull strings with Stepper motors but could not run it fast and strong enough with the smaller existing controllers, and bigger controllers will not fit in space. So I am fitting dc motors with worm gears.
8. Sound wireless. Done but needs testing when all is done as there are some distortion.
9. I can easily change between E9 tuning to C6 tuning by selecting on the touch screen.
As you would imagine, the design is quite involve and I normally struggle to get the code running as expected. I am relatively new in coding.
Attach a photo
@jdebruyn Welcome to the forum. That's an interesting project.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
I love it! Will be following when you get it going.
Patrick
@Fidodie - Fy-doh-dee
I have two questions.
1. With regards to load cell's. I have 12 load cells and run 6 with master esp and 6 with slave esp. As I ran out of pins on the esp32's can I use one pin to handle all 6 clock's and have the data on its own digital pin. As the code snip indicate.
I need the data to be available all the time so do not want to use a multiplexer if not needed.
HX711 scales[6];
const uint8_t dataPin[6] = {12, 26, 25, 14, 27, 18}; // 6 Digital Data Pins
const uint8_t clockPin = 5; // Shared Clock Pin for HX711 Modules
2. I use 2 esp32's that need to read 12 hull effect sensors, 12 load cells and run dc motors when requested by pedals data and knee levers. Normally max two motors a time. Do I ask too much or will the esp's run with a smile?
@jdebruyn Sorry buddy, you understand what you are saying because you are deep inside your project. Without seeing ALL the code (posted inside the <> ^^^^) we don't have a hope of understanding. Even with the code, we still need to do a lot of catching up. If you give us enough info there is a lot of experience here but expect lots of questions.
I worry that sharing the clock pin will draw more current than the ESP32 can provide. I also don't believe you can't multiplex, the load cells are relatively slow acting devices.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, 360, fairly knowledge in PC plus numerous MPU's & MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.
Hi all. I am looking for help. In the attach code I tried to code DC motors to adjust a Electro Steel Guitar project I am busy with. The motors needs to behave as follow.
I have a Touch-Screen controlled by a esp32display, when I touch "1" and "UP" the unit will transmit via esp_WiFi, Value_String1 =1 and Value_StringUP = 1. When the motor receive that values it should soft-start and ramp up to speed, and when Value_StringUP = 0 the motor needs to stop without ramping down.
On the other hand when Value_String1 = 1 and Value_StringDOWN = 1 then motors to run back without soft-start and when conditions go back to "0" motors to stop without ramping down.
Currently the motors do start up but do not stop and I dont know enough to make it to work correctly.
The next step will be to input via WiFi a frequency to each motor control that when I select Auto = 1 the motors will run forward or back depends on the string frequency. That will be used to auto-adjust the strings.
It will be great if I can get help please.
#include <FS_MX1508.h>
#include <WiFi.h>
#include <esp_now.h>
#define pinA 23 // to be adapted to your configuration. Here ESP32 ...
#define pinB 22 // to be adapted to your configuration. Here ESP32 ...
MX1508 motorA(pinA, pinB); // default SLOW_DECAY (resolution 8 bits, frequency 1000Hz)
uint8_t sender3_MAC[] = {0xd8, 0x3b, 0xda, 0x85, 0x38, 0x5c}; // Screen myData1
typedef struct {
float Slider1;
float Slider2;
int Value_SelectC;
int Value_SelectCsharp;
int Value_SelectA;
int Value_SelectB;
int Value_SelectBb;
int Value_SelectD;
int Value_SelectFb;
int Value_SelectE;
int Value_SelectFsharp;
int Value_SelectG;
int Slider_LUP;
int Slider_LL;
int Slider_LR;
int Slider_RR;
int Slider_RL;
int Value_AutoAdjust;
int Value_StringUP;
int Value_StringDOWN;
int Value_String1;
int Value_String2;
int Value_String3;
int Value_String4;
int Value_String5;
int Value_String6;
int Value_String7;
int Value_String8;
int Value_String9;
int Value_String10;
int Value_String11;
int Value_String12;
} struct_message;
struct_message myData1;
bool motorRunningForward = false;
bool motorRunningBackward = false;
void OnDataRecv(const esp_now_recv_info_t *info, const uint8_t *incomingData, int len) {
const uint8_t *mac = info->src_addr; // Extract sender's MAC address
if (memcmp(mac, sender3_MAC, 6) == 0) {
memcpy(&myData1, incomingData, sizeof(myData1));
Serial.println("Data received from Sender 1 (myData1)");
Serial.print("StringDOWN: "); Serial.println(myData1.Value_StringDOWN);
Serial.print("StringUP: "); Serial.println(myData1.Value_StringUP);
Serial.print("String1: "); Serial.println(myData1.Value_String1);
Serial.print("String2: "); Serial.println(myData1.Value_String2);
Serial.print("String3: "); Serial.println(myData1.Value_String3);
Serial.print("String4: "); Serial.println(myData1.Value_String4);
Serial.print("String5: "); Serial.println(myData1.Value_String5);
Serial.print("String6: "); Serial.println(myData1.Value_String6);
motorRunningForward = false; // Reset motorRunningForward flag on new data received
motorRunningBackward = false; // Reset motorRunningBackward flag on new data received
}
}
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
if (esp_now_init() != ESP_OK) {
Serial.println("ESP-NOW Init Failed!");
// Handle initialization failure (e.g., retry or enter a safe state)
return;
}
esp_now_register_recv_cb(OnDataRecv);
Serial.println("ESP-NOW Receiver Ready.");
}
void loop() {
// MotorA runs forward until condition changes
if (myData1.Value_String1 == 1 && myData1.Value_StringUP == 1) {
if (!motorRunningForward) {
Serial.println("MotorA ramp up forward 0 to 200");
for (int pwm = 0; pwm <= 200; pwm++) { // ramp up forward
motorA.motorGo(pwm);
delay(50);
}
motorRunningForward = true; // Set motorRunningForward flag
motorRunningBackward = false; // Ensure backward flag is reset
} else {
motorA.motorGo(200); // Keep running forward
}
}
// MotorA runs backward until condition changes
else if (myData1.Value_String1 == 1 && myData1.Value_StringDOWN == 1) {
if (!motorRunningBackward) {
Serial.println("MotorA ramp up backward 0 to -200");
for (int pwm = 0; pwm <= 200; pwm++) { // ramp up backward
motorA.motorGo(-pwm);
delay(50);
}
motorRunningBackward = true; // Set motorRunningBackward flag
motorRunningForward = false; // Ensure forward flag is reset
} else {
motorA.motorGo(-200); // Keep running backward
}
}
// Stop the motor if the conditions are not met
else {
if (motorRunningForward || motorRunningBackward) {
Serial.println("MotorA stopping");
motorA.motorStop();
motorRunningForward = false; // Reset motorRunningForward flag
motorRunningBackward = false; // Reset motorRunningBackward flag
}
}
delay(100); // Adjust delay as needed
}