Pages: [1]   Go Down
Author Topic: Web server and servo interaction (BlackWidow)  (Read 4762 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 1
Posts: 28
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...


Logged

Sydney, Australia
Offline Offline
Full Member
***
Karma: 3
Posts: 230
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Is life really that serious...??!

0
Offline Offline
Newbie
*
Karma: 1
Posts: 28
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...

Logged

Pages: [1]   Go Up
Jump to: