Remember when connecting a separate power supply to the motor to connect the 0V of the motor supply to the GND of the arduino. If Vcc drops to 4.5V then the input to the ADC will be 2.25V and the output from the ADC will still be 512 (2.25/4.5 * 1024). If the pot is set midway and with Vcc at 5V then the input to the ADC will be 2.5V and the ADC will read 512. In your case of trying the sketch with a pot across Vcc and Gnd you cancel out any variation in Vcc.Į.G. The analogWrite() function uses PWM, so if you want to change the pin youre using, be sure to use another PWM capable pin. if the controller is outputting 2.5v the with the Vcc rail at 5V the ADC will read 2.5/5 * 1024 = 512 but if the motor causes Vcc to drop to 4.5V then the ADC will read 2.5/4.5 * 1024 = 568. If the motor is pulling significant current and causing Vcc to drop then the analogRead() value will change.Į.G. The default setting for an arduino ADC is to use Vcc (+5V) as the analogue reference for the ADC. I think what is happening is that excessive current to the motor is causing the Vcc rail on the to drop. The 5V from an arduino board is not suitable for driving high current devices like motors. Try powering the motor from a separate power supply not from the arduino. print the results to the serial monitor: map it to the range of the analog out: put your main code here, to run repeatedly: Serial.begin(9600) // Definir la vitesse en Baud (Données/sec) PinMode(inPin, INPUT) // Definir la pin en tant que sortie PinMode(outPin, OUTPUT) // Definir la pin en tant que sortie put your setup code here, to run once: When I delete this function, the value received returns unstable. I can receive stable value from the PLC to change the motor speed but when I write it in an analogWrite() function to control the motor, this value become unstable. Octopus Motor Brick(EF04059) - ELECFREAKS WIKI with a Siemens PLC. I'm a beginner in Arduino and I try to control this motor 15.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |