I'm trying to power a brushless motor using a CGI script on a website, executed by python. My setup is as follows
Web server running on Raspberry Pi hosting a website with a button and a slider. This is connected to Arduino (DUE) via a USB to the programming port. When a button is pressed, or the slider is used, a python CGI script is run, the script is as follows:
There many stages from your script to the motor. Have you checked these intermediate results?
In any case you need to give much more detail for anyone to help.
The below part of your code is probably causing the arduino to reset. You may need a 100 ohm resistor between the arduino +5v and reset pins to defeat the reset.
ser = serial.Serial('dev/ttyACM0', 9600)
ser.write("%s\n" % (form["value"]))
ser.close()
Others have used something like a 5mf capacitor between the arduino reset pin and ground to defeat the reset. You can open and close the serial monitor and watch the arduino LED to see if it looks like it is resetting.
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
delay(3000);
}
void loop() {
if (Serial.available() > 0) {
byte incomingByte = Serial.read();
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
digitalWrite(13, HIGH); // set the LED on
delay(100); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(100); // wait for a second
}
And your python script (bugfixed), executing it from the command line:
The blinking does not indicate any type of reset of the Arduino. I'm running this on a Linux box -- not the Raspberry Pi.
I also checked the pySerial documentation and, by default, it does not use hardware reset.
Are you sure that your motor circuit itself is not causing the reset? Try putting a delay in your python script to see if it really is the short execution of the script that causes the behavior?
void loop() {
if (Serial.available() > 0) {
byte incomingByte = Serial.read();
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
digitalWrite(13, HIGH); // set the LED on
delay(100); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(100); // wait for a second
}
And your python script (bugfixed), executing it from the command line:
The blinking does not indicate any type of reset of the Arduino. I'm running this on a Linux box -- not the Raspberry Pi.
I also checked the pySerial documentation and, by default, it does not use hardware reset.
Are you sure that your motor circuit itself is not causing the reset? Try putting a delay in your python script to see if it really is the short execution of the script that causes the behavior?
No luck I'm afraid. From what I'm seeing around the place it looks like it's related to the machine that's opening the serial port, so in this case the raspberry pi. Some computers you can turn it off, but not with the pi.
That's what it looks like anyway... well will just have to find a way around!