Baby Mobile (ARM Cortex-M3, vs1053b, L298N) - Help welcomed

Have questions about a SparkFun product or board? This is the place to be.

Moderator: phalanx

Re: Baby Mobile (ARM Cortex-M3, vs1053b, L298N) - Help welco

Postby nineball » Sun Dec 04, 2011 8:39 pm

A little thread necromancy but I'm back on the project after actaully raising my child for the last 9 months and want to finish this before Christmas for him. I'm having a tough time of the PWM and L298 motor driver though. I'm using the LPC17xx driver library with PWM1.1 out and it toggles an LED at the rate I'd expect, decreasing brightness based on my parameters. When I connect it to the L298 enable pin however, the driver does not seem to slow down at all. I am leaving it tied at forward only as that is all I require and pulsing the enable pin. I tried leaving enable high and pulsing the input but that did not change anything. PyroElectro has a tutorial where they made their own "PWM" and in the code are actually flipping which inputs are high and which are low. Throwing it in forward/reverse like that doesn't make sense to me but their video shows it working and that's more than I can say for me. Help please!
nineball
 
Posts: 20
Joined: Sat Nov 20, 2010 10:42 am

Re: Baby Mobile (ARM Cortex-M3, vs1053b, L298N) - Help welco

Postby nineball » Mon Dec 05, 2011 10:05 am

I think I may have an idea of what is going on. Looking at my code, I set MR0 to 256 which results in a PWM frequency well above what it should be (I need to confirm my PCLK, but I'm pretty sure the LPCXpresso has it running at 25MHz which would be a ~97.6kHZ PWM) so that the L298N simply cannot keep up and just stays high. According to various online boards, it looks like a lot of people use 1-20kHz as their frequency (the PyroElectro example was 1kHz). The L298N datasheet states a typical fc(Vi) commutation frequency of 25kHz with a maximum of 40kHz. As a relative newbie at this, I'm not sure if I should be aiming to match my PWM frequency to that (25kHz) or just go with what I've seen work (1kHz). Assuming I have a PCLK of 25MHz and want to reach a PWM of 25kHz (or 1kHz), I would set my MR0 to 1,000 (or 25,000); correct?
nineball
 
Posts: 20
Joined: Sat Nov 20, 2010 10:42 am

Re: Baby Mobile (ARM Cortex-M3, vs1053b, L298N) - Help welco

Postby nineball » Mon Dec 12, 2011 9:54 pm

Turns out my code and setup were perfectly fine (although my PWM was too high). I had my LPCXpresso powered using the VIO_3V3X pin which should have been fine but apparently was not and switching over to EXT_POWX fixed everything. I seem to not have any trouble running the motor with a duty cycle of 20-25% but any lower than that and the motor will not start. The one thing that's bugging my now is the whine the motor emits when using the 1kHz frequency. I quickly tried a test at 10kHz but even at 50% duty cycle the motor would not start and it's time to call it a night. Any ideas on the commutation frequency of 25kHz being a usable value for my PWM?
nineball
 
Posts: 20
Joined: Sat Nov 20, 2010 10:42 am

Re: Baby Mobile (ARM Cortex-M3, vs1053b, L298N) - Help welco

Postby nineball » Tue Feb 28, 2012 9:42 pm

I still am having frequency problems with the motor controller but have moved on. I am now trying to send a music file to the VS1053b when it's data request pin (DREQ) goes high. I am using the same method as the MP3 belt buckle tutorial to catch this event, which is to attach it to CAP0.0. When it didn't work, I tried pulling the pin high/low manually and still could not get it to work. I am using CMSIS 1.3 and the LPC17xx CMSIS Driver Library and have copied over the relevant code:

Code: Select all
TIM_TIMERCFG_Type TIM_ConfigStruct;
TIM_CAPTURECFG_Type TIM_CaptureConfigStruct;

LPC_PINCON->PINSEL3 |= (0x20300015);

TIM_ConfigStruct.PrescaleOption = TIM_PRESCALE_TICKVAL;
TIM_ConfigStruct.PrescaleValue = 125;

TIM_CaptureConfigStruct.CaptureChannel = 0;
TIM_CaptureConfigStruct.RisingEdge = ENABLE;
TIM_CaptureConfigStruct.FallingEdge = DISABLE;
TIM_CaptureConfigStruct.IntOnCaption = ENABLE;

TIM_Init(LPC_TIM0, TIM_TIMER_MODE, &TIM_ConfigStruct);
TIM_ConfigCapture(LPC_TIM0, &TIM_CaptureConfigStruct);

NVIC_SetPriority(TIMER0_IRQn, ((0x01<<3)|0x01));
NVIC_EnableIRQ(TIMER0_IRQn);

TIM_ResetCounter(LPC_TIM0);
TIM_Cmd(LPC_TIM0, ENABLE);

...

void TIMER0_IRQHandler(void) {
  if (TIM_GetIntCaptureStatus(LPC_TIM0, 0) == SET) {
    while(LPC_GPIO1->FIOPIN & (1<<26)){
      SDtoCoProcessor();
    }
  }
  TIM_ClearIntCapturePending(LPC_TIM0, 0);
  return;
}


When I stick a breakpoint on the handler function it never hits it even when I manually toggle the capture pin. As a last ditch I can try to simply connect DREQ to any old GPIO set up as an external interrupt but this should work either way. Any help is appreciated here especially as I am already late on getting this project done.
nineball
 
Posts: 20
Joined: Sat Nov 20, 2010 10:42 am

Previous

Return to SparkFun Product Questions

Who is online

Users browsing this forum: No registered users and 4 guests