chipKIT® Development Platform

Inspired by Arduino™

DP32 and Servos

Created Mon, 22 Dec 2014 21:13:24 +0000 by GastonLagaffe


GastonLagaffe

Mon, 22 Dec 2014 21:13:24 +0000

Salut, I am testing the DP32 to drive a servo. I saw in the pinmap that pins 2,3,6,8 and 13 should be able to use PWM to drive the servo. However, none of them gets my servo to move. I tested the servo with the uno32 and it is ok using pin3 of the uno32 I tested DP32 with Softservo and that works.

Any advice is appreciated

Ciao, Mathias


djgardn2

Mon, 22 Dec 2014 22:17:51 +0000

Ignore this post, see response below.

Pin numbers look correct.


majenko

Mon, 22 Dec 2014 22:22:58 +0000

Those definitions are only for reading analog values through the ADC. You need to be looking in the file Board_Data.c for the digital_pin_to_timer_PGM[] table. The _TIMER_OC* entries are the PWM pins.


GastonLagaffe

Tue, 23 Dec 2014 07:50:13 +0000

Salut,

according to that table, the PWM pins are 2,3,6,8 and 13. However, this seems not to work as I already tried 2,3,6 and 8

Ciao, Mathias


majenko

Tue, 23 Dec 2014 10:20:18 +0000

I'm not too up on the default configuration of the DP32. It may well be that you will have to manually map the OCx functions to the right pins with mapPps().


GastonLagaffe

Mon, 29 Dec 2014 19:43:11 +0000

Salut,

I hope you all had a nice Christmas Break! I have tried to run a servo using mapPps but still here there is no success. The data-sheet states that the OCx functions are already mapped. Anyway, my goal is to use a servo so any working code is welcome. The softPWM Version is working, so this is non-critical.

Ciao, Mathias


EmbeddedMan

Thu, 01 Jan 2015 18:22:23 +0000

Mathias,

I had no trouble producing PWM output on the default OC pins using the following test code:

void setup()  {
} 

int x = 0;

void loop()  { 
  analogWrite(8, x);
  analogWrite(2, x);
  analogWrite(3, x);
  analogWrite(13, x);
  analogWrite(6, x);
  delay(100);
  x = x + 8;
  if (x > 255) {
	x = 0;
  }
}

Do you have some custom code that's manipulating the OC registers to generate the RC Servo pulses? If you do, please post it and I can try testing it here.

*Brian


GastonLagaffe

Fri, 02 Jan 2015 15:44:35 +0000

Salut Brian,

I am trying to use the servo example from the servo library. I can use it easily with the PWM pins of the ChipKit Uno32 but I cannot get them to work with the DP32. SoftPWM works on all pins.

Ciao, Mathias


EmbeddedMan

Fri, 02 Jan 2015 18:17:02 +0000

OK, so I took the SWEEP example sketch and changed the myservo.attach(9); to a myservo.attach(8); and now I can see a proper servo pulse being emitted from RB15 on my DP32. I'm guessing that the others pins will work just as well.

So the example code appears to be working for me.

Can you try the above experiment and see if you can get the same result?

*Brian


GastonLagaffe

Sat, 03 Jan 2015 18:27:06 +0000

Salut Brian,

this is puzzling ... I run the sweep sketch as you mentioned using pin 8 and I get only noise on the pin (using my scope). When I run the SoftPWM sketch on pin 8 I get the proper servo pwm (20ms wavelength, 1-2ms pulse-width, 3.3V). I tried it on an original DP32 as well as on my HelvePic32 board. I also swapped UECIDE with mpide without any change. I run the sketch on my Uno32 and it works ...

Ciao, Mathias


EmbeddedMan

Sun, 04 Jan 2015 01:22:45 +0000

Mathias,

Just for giggles, try using the latest MPIDE test build we did today: [url]https://chipkit.s3.amazonaws.com/builds/mpide-0150-windows-20150103-test.zip[/url]

See if that works for you. (That's what I did my testing with.)

*Brian


GastonLagaffe

Sun, 04 Jan 2015 10:45:05 +0000

Salut Brian,

when using the suggested MPIDE test build, the servo example works. So it must be with the DP32 definition files ... I will download and test with the latest UECIDE beta as well

Ciao, Mathias


majenko

Sun, 04 Jan 2015 10:55:08 +0000

It may be an old version of the core not doing the mapPps right though - not sure UECIDE would help in that case...

Try it and see - if it doesn't work then try the chipKIT-Git core and pic32-tools-MZ compiler to see if that works