Need testers for SoftPWMServo library

EmbeddedMan
Posts: 597
Joined: Tue May 24, 2011 9:24 pm
Location: Minneapolis, MN
Contact:

Re: Need testers for SoftPWMServo library

Post by EmbeddedMan » Sun Dec 23, 2012 12:03 am

OK. When I run that code, it gives me the right duration of pulses. So I'm not sure what's different in your case.

*Brian

PICedh
Posts: 64
Joined: Tue May 15, 2012 8:17 pm
Location: Paris
Contact:

Re: Need testers for SoftPWMServo library

Post by PICedh » Sun Dec 23, 2012 3:34 pm

hello,

I have followed your first recommendation, I have increased the frame time from 80000 ticks to 100000 ticks and it works


I still don't understand why it works fine without any change with the standard servo lib

for info SOFTPWMSERVO_DEFAULT_FRAME_TIME = 80000
and CORE_TICKS_PER_US = 40


here my new code:


void setup()
{
Serial.begin(9600); // initialize serial port
}

void loop()
{
SoftPWMServoSetFrameTime (100000);
SoftPWMServoRawWrite(34, 100000,SOFTPWMSERVO_SERVO); // Left
delay (5000);
SoftPWMServoRawWrite(34, 60000,SOFTPWMSERVO_SERVO); // center
delay (5000);
SoftPWMServoRawWrite(34, 20000,SOFTPWMSERVO_SERVO); //right
delay (5000);
RobotEdh: My first Robot is controlled by a chipKIT Max32

PICedh
Posts: 64
Joined: Tue May 15, 2012 8:17 pm
Location: Paris
Contact:

Re: Need testers for SoftPWMServo library

Post by PICedh » Sun Dec 23, 2012 3:34 pm

hello,

I have followed your first recommendation, I have increased the frame time from 80000 ticks to 100000 ticks and it works


I still don't understand why it works fine without any change with the standard servo lib

for info SOFTPWMSERVO_DEFAULT_FRAME_TIME = 80000
and CORE_TICKS_PER_US = 40


here my new code:


void setup()
{
Serial.begin(9600); // initialize serial port
}

void loop()
{
SoftPWMServoSetFrameTime (100000);
SoftPWMServoRawWrite(34, 100000,SOFTPWMSERVO_SERVO); // Left
delay (5000);
SoftPWMServoRawWrite(34, 60000,SOFTPWMSERVO_SERVO); // center
delay (5000);
SoftPWMServoRawWrite(34, 20000,SOFTPWMSERVO_SERVO); //right
delay (5000);
RobotEdh: My first Robot is controlled by a chipKIT Max32

danialn
Posts: 3
Joined: Fri May 04, 2012 11:14 pm

Re: Need testers for SoftPWMServo library

Post by danialn » Mon Mar 18, 2013 8:17 pm

Hello,

I have modified a the ServoTest that comes with the SoftPWMServo Library to run a servo clockwise (1.0 ms pulse) for 3 seconds, stop (1.5 ms pulse) for 1 second, then CCW (2.0 ms pulse) for 3 seconds, finally stop (1.5 ms pulse) for 1 second, then repeat. I checked the output with the scope and the second 1.5 ms pulse does not appear. The 1 second time delay and LD5 goes off for the one second as shown in the code. (I have added code to turn on the LED on the ChipKIT UNO32 (pin 43) when the servo is running and turn off the LED when the servo is supposed to be stopped.) After watching the operation of the servo, The scope shows that everything is fine except for the second 1 second pulse of 1500 ms to stop the servo. I have pasted the code below. can anyone tell me what I might be missing here?

#include <SoftPWMServo.h>


int pos = 0; // variable to store the servo position, in microseconds
const int pin = 8; // Choose _any_ pin number on your board
const int LEDpin = 43;

void setup()
{
SoftPWMServoInit(); // not supposed to be necessary, but a good idea.
SoftPWMServoPinEnable(pin,OUTPUT);
pinMode(LEDpin,OUTPUT);

}

void loop()
{
// DIRECTION ClockWise
pos = 1000;
SoftPWMServoServoWrite(pin, pos);
digitalWrite(LEDpin,HIGH);
delay(3000);

// STOP
pos = 1500;
SoftPWMServoServoWrite(pin, pos);
digitalWrite(LEDpin,LOW);
delay(1000); // waits 1 second before changing positionss

// Direction CounterClockWise
pos = 2000;
SoftPWMServoServoWrite(pin, pos);
digitalWrite(LEDpin,HIGH);
delay(3000);

// STOP
pos = 1500;
SoftPWMServoServoWrite(pin, pos);
digitalWrite(LEDpin,LOW);
delay(1000); // waits 1 second before changing positionss


}

Thank you,

Dan

EmbeddedMan
Posts: 597
Joined: Tue May 24, 2011 9:24 pm
Location: Minneapolis, MN
Contact:

Re: Need testers for SoftPWMServo library

Post by EmbeddedMan » Wed Mar 20, 2013 4:35 am

Dan, I just ran you code, and I did not see the same problem you are. It worked perfectly for me (always outputting pulses, even during both 1 second long 1.5ms times). I used a Fubarino SD and my scope to verify the output of pin 8.

I'm not sure what could be going wrong with your setup. Can you try a different I/O pin maybe?

*Brian

Andres
Posts: 4
Joined: Fri Mar 15, 2013 2:00 pm

Re: Need testers for SoftPWMServo library

Post by Andres » Tue Mar 26, 2013 5:34 pm

Hello,
I have a few questions regarding this library:

1.- Wich is the maximum resolution achived for the PWM signals? as I read on the README at github It looks like the tick is just 1 ms, I'm right?

2.- Does It depend so badly to the arduino IDE or structure? I'm trying to compile it for MPLAB X but it has a lot of dependencies from arudino/chipkit libraries. Do you have a core to port it straight to C?

Thank you very much.

EmbeddedMan
Posts: 597
Joined: Tue May 24, 2011 9:24 pm
Location: Minneapolis, MN
Contact:

Re: Need testers for SoftPWMServo library

Post by EmbeddedMan » Tue Mar 26, 2013 7:04 pm

Anders,

The ideal resolution (although, NOT guaranteed) is 1/40MHz, or 25ns. That's what gets used to decide when the next edge will occur. However, there are things that will add jitter to each edge and so you can't count on 25ns accurate edges. Because it's a software library, you will have to actually prototype your system and measure it to see what kind of jitter you get when you're running your code. But with just one servo running, it's pretty easy to get close to 25ns accuracy.

I do not have a pure C version of the library, although there are very few things that it depends on that are Arduino specific, so porting it should be pretty easy.

*Brian

mrk3rmit
Posts: 1
Joined: Wed Apr 17, 2013 2:56 pm

Re: Need testers for SoftPWMServo library

Post by mrk3rmit » Wed Apr 17, 2013 3:00 pm

Excuse me all. Where can i download the libarary?

The link given give me this error
"Not Found

The requested URL /UBW32/SoftPWMServo_v1_0.zip was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."

thx in advance :)

EmbeddedMan
Posts: 597
Joined: Tue May 24, 2011 9:24 pm
Location: Minneapolis, MN
Contact:

Re: Need testers for SoftPWMServo library

Post by EmbeddedMan » Sun Apr 21, 2013 12:55 pm

Download any recent (in the last year) MPIDE build, and the library comes as part of MPIDE. Go to http://chipkit.net/started/install-chipkit-software/ and download MPIDE. You'll find the SoftPWMServo library in the libraries folder.

*Brian

cobra18t
Posts: 24
Joined: Wed Dec 21, 2011 2:23 am
Contact:

Re: Need testers for SoftPWMServo library

Post by cobra18t » Thu Aug 15, 2013 11:52 pm

I am having a similar issue to one previously mentioned. Every 107 seconds, the raw PWM that I use to drive 4 SSRs arranged in an H-bridge fails. After a number of seconds (20-60?), the PWM comes back and I can control my motor again.

This points to a Core Timer overflow issue, but I thought that was addressed in version 1.1 of the library. I am using the SoftPWMServo library bundled with 20120903 MPIDE.

Everything else (LED debugging) in my sketch continues to work when the PWM fails, so I am getting to all the other parts of my code. Since it fails and eventually comes back, it is like the callback is being told the wrong Core Timer count to update.

I have 8 PWM outputs controlling 2 SSR-based H-bridges. I am dealing with low frequencies in the 40-100Hz range on the PWM. PWM duty is updated at a rate around 30Hz.

Any ideas what could cause this?


-Thomas

Post Reply