ESP32Cam and Servo Control
-
- Posts: 9
- Joined: Tue Jul 09, 2019 12:50 am
ESP32Cam and Servo Control
I'm sorry if this is the wrong forum to ask this in. A friend of mine gave me an ESP8266 a few months back and now I'm hooked no making gadgets and devices of all kinds. I recently bought several ESP32 boards and 2 ESP32Cam boards.
I'd like to use the ESP32Cam to be able to control it's own Pan/Tilt mount that I am building using 2 small servo motors (MS18). I have tested the servo control code and it works fine, and I have tested the camera streaming code and that works fine as well. However, when I build the sketch with the camera streaming enabled then the servo motors do not work.
I have been able to interface with other things while the camera is enabled, specifically the DHT11 Temperature/Humidity sensor. That works fine. It's almost like when the camera is in use the ESP32Cam is not able to do PWM (maybe the camera module is using up all of the available system timers? I honestly have no idea).
Is this by design and I just missed that somewhere? Is there something I need to do to make it work?
Thanks in advance!
I'd like to use the ESP32Cam to be able to control it's own Pan/Tilt mount that I am building using 2 small servo motors (MS18). I have tested the servo control code and it works fine, and I have tested the camera streaming code and that works fine as well. However, when I build the sketch with the camera streaming enabled then the servo motors do not work.
I have been able to interface with other things while the camera is enabled, specifically the DHT11 Temperature/Humidity sensor. That works fine. It's almost like when the camera is in use the ESP32Cam is not able to do PWM (maybe the camera module is using up all of the available system timers? I honestly have no idea).
Is this by design and I just missed that somewhere? Is there something I need to do to make it work?
Thanks in advance!
-
- Posts: 9
- Joined: Tue Jul 09, 2019 12:50 am
Re: ESP32Cam and Servo Control
I think I resolved it. It looks like I just need to specify higher numbered timers for the servos. I wasn't able to get the servos to work using timers 1 or 2, but 5 seems to work fine.
-
- Posts: 16
- Joined: Fri Jul 05, 2019 4:35 am
Re: ESP32Cam and Servo Control
Yep, first timer is used to generate the camera clock. Dont use timer1 and timer2 while running camera.
Re: ESP32Cam and Servo Control
Different camera (Raspberry camera), and only tilt calibration (my camera has no Pan).MadScientist wrote: ↑Tue Jul 09, 2019 1:00 am... I'd like to use the ESP32Cam to be able to control it's own Pan/Tilt mount that ...
But the automatic calibration code in this posting might be interesting/useful to you with ESP32-CAM as well:
https://www.raspberrypi.org/forums/view ... 1#p1231151
In this posting I added µs resolution waveform generation to FCameraWebServer:
https://www.esp32.com/viewtopic.php?f=1 ... 079#p46079
In this thread you can see how to add new features to Examples->ESP32->Camera->CameraWebServer:
https://www.esp32.com/viewtopic.php?f=19&t=11190
In this thread you can see how @VladTheImpaler did RC/PWM control a tank based on CameraWebServer:
https://www.esp32.com/viewtopic.php?f=19&t=11337
-
- Posts: 16
- Joined: Fri Jul 05, 2019 4:35 am
Re: ESP32Cam and Servo Control
If the HTML RC wasnt slow / inaccurate i would fly copters with it.
An esp32-cam can do what this one does:
An esp32-cam can do what this one does:
Re: ESP32Cam and Servo Control
That is a good point, I will have to build in a heartbeat signal between intex.html(browser) and app_httpd.cpp(ESP32) and let the ESP32 do "full stop" automatically when no heartbeat received, at least for the 5m/s caterpillar robot.VladTheImpaler wrote: ↑Tue Jul 09, 2019 12:26 pmIf the HTML RC wasnt slow / inaccurate i would fly copters with it.
For indoor use "full stop" will be different to what one normally thinks in order to minimize linear braking distance.
Robot will do full U-turn as shown here (robot did 2.5m/s, just revert one motor direction, keep speed of both motors).
And it will NOT stop the U-turn but keep turning.
While turning it will reduce speed of the motors to 0.
This will not reduce the total braking distance, but the linear braking distance since robot will keep turning locally until stopped.
https://forum.arduino.cc/index.php?topi ... msg3236016
Re: ESP32Cam and Servo Control
> RC wasnt slow / inaccurate
>
I just tested a newly arrived ESP32-CAM module, and the FCameraWebServer reported framerates were much less than with my current working ESP32-CAM module. It turned out to be Wifi problems, since after I added an external Wifi antenna to the new ESP32-CAM module framerates are much higher, and the sketch became really reliable:
>
I just tested a newly arrived ESP32-CAM module, and the FCameraWebServer reported framerates were much less than with my current working ESP32-CAM module. It turned out to be Wifi problems, since after I added an external Wifi antenna to the new ESP32-CAM module framerates are much higher, and the sketch became really reliable:
-
- Posts: 9
- Joined: Tue Jul 09, 2019 12:50 am
Re: ESP32Cam and Servo Control
So just a followup, now that I've got the camera working with the servo I wanted to add a 2nd servo. However no matter what I do, as soon as I add the 2nd servo the unit just starts endlessly rebooting with brownout warnings. I've tried various USB cables, various power sources, etc. So far no matter what I do the unit will not handle 2 servos. I've also tried with just a Node32s (non-camera) board and got the same thing. Do I need a second power source just for the servos? That would be a little inconvenient for the project I had in mind but if it's required then it's required.
Thoughts, anyone?
Thanks for all the great feedback and sharing of projects so far. This is wildly fascinating to me and is a leading contributor to my lack of "going outside-ness"
Thoughts, anyone?
Thanks for all the great feedback and sharing of projects so far. This is wildly fascinating to me and is a leading contributor to my lack of "going outside-ness"
Re: ESP32Cam and Servo Control
You need a separate power source for the servos:
https://forum.arduino.cc/index.php?topi ... msg3211401
https://forum.arduino.cc/index.php?topi ... msg3211401
Don't try to power servos or motors from the 5V output of an Arduino. You will damage the Arduino if you do so.
Use a separate power supply for the servos, and connect the grounds together.
Servos can consume 5 or more watts while moving.
...
-
- Posts: 9
- Joined: Tue Jul 09, 2019 12:50 am
Re: ESP32Cam and Servo Control
Thats more or less what I though... What I ended up doing last night, and this seemed to work, was to use a double headed USB cable from an older USB hard drive. This let me draw power from two usb ports but still only need ONE connection going to the ESP32 and servos. I then moved the servos draw off of the ESP32 and just had them draw directly from the power coming down the usb wire before it hit the ESP32. That seems to have worked and the unit is really stable. As a happy side effect the chip is running significantly cooler now too.
I guess that all makes sense now that I think about it.
Thanks, all. You've been a great help! This is fun!
I guess that all makes sense now that I think about it.
Thanks, all. You've been a great help! This is fun!
Who is online
Users browsing this forum: No registered users and 53 guests