Go Down

Topic: Web server and servo interaction (BlackWidow) (Read 5097 times) previous topic - next topic

whatevernot

Hello:

I have a BlackWidow wifi arduino, and it's very cool.

Run into a snag - I am using the supplied web library (#include WiShield.h) and have a web server up - this handles GET requests (return JSON) and as well you can POST a JSON object, and it updates data accordingly.

I'm using this to right now control 2 servos ("s1" and "s2") so the position is set from values in the JSON object POSTed to the server.

So, for example, POSTing:

{ "s1": 0, "s2": 120 }

to the arduino ultimately results in the following calls to update the servos (the Servo object defined in the standard arduino servo lib):

this->servo1_.write(0);
this->servo2_.write(120);

You can make a GET request and get back the JSON:

{ "s1": 0, "s2": 120 }

If I run with the servo updates commented out, it works. When I uncomment the code, the server runs fine for a bit (and servos rotate) but then it crashes (?) I think it crashes - it doesn't respond to GET requests - seems dead.

May take a bit, but eventually does, and so I'm wondering if there might be a timing thing with the servo rotation code causing problems with the network library?

It's got me stumped so far - any hints appreciated.

Cheers,

brian...



pocketscience

How are you powering your servos? How much current do they draw?

Is life really that serious...??!

whatevernot

Oh my! I was powering the arduino and servos from the USB cable. I changed to power from an external power supply (9V 650mA) and seems to be working fine now.

I'm a software guy, not a hardware person.

Did a quick test, and everything looks to be working okay!

Wicked news - thanks a ton, pocketscience.

Cheers.

brian...


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy