Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
9 years ago

Deo Nano Beginer problem

Dear All,

I am new to FPGA (also to vhdl), and altera deo nano is my first board.

I tried to generate pwm to some pins, and I generated 4 pwms using this core https://eewiki.net/pages/viewpage.action?pageid=20939345

in my state machine I used something like this. (there are 4 in total, i showed one here)

----------------------------------------------------------------------

Motor1CCW_task2: pwm

GENERIC MAP(sys_clk => sys_clk1, pwm_freq=> pwm_freq1, bits_resolution => bits_resolution1, phases => phases1)

PORT MAP(clk => clk_main, reset_n => '1', ena => '1', duty =>"10000000" , pwm_out=> Motor1_CCW --, pwm_n_out => Motor1_CW

);

-------------------------------------------------------------------------

I used l293d ic to drive two motors. At the beginning, I able to change duty cycle and direction and motors. But after working for 30 min, the motors stared weird behavior and I noticed pwms are wrongly generated.

Now doing plenty of permutations I cant figure out what is going on. It seems some times, some pins not working. for example If I try to use GPIO_131 (k15) it seems broken and the attempt to use it also affect other pins. and also some pins cant generate pwm as expected. Again if i changed "Motor1_CCW" to different specific pins, it works.

---I changed to all unused pins as tri-stated

---the voltage level i selected 3.3 lvttl

Later I started with a new deo nano, the exact thing happened. works perfectly at the beginning and then started weird behavior. The motor circuit is simple and motors were run at 6 volt. I suspect that some pins of deo nano are broken both cases. But the control panel(deo_nano_controlpanel.exe) works perfectly for the boards.

Any suggestion?

Thank you very much

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    You need special motor drive electronics to interface motors to PWM circuits. If you don't have that correct you can damage the output pins on the FPGA. An FPGA pin operates at a very low voltage and sources a tiny amount of current (3.3 volts at 8 microamps iirc?). The l293d is an hbridge driver. I know nothing about motors, but I've only seen hbridge circuits used to drive motors at full power in either forward or reverse. I've never seen them used with pwm. Someone who knows about motors can tell you where to find a good circuit to control a DC motor with a FPGA generated pwm signal.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi,

    As Galfonz said, a driver chip is a hard requirement. Okay, you could also do this manually with FETs, but you'll need FET drivers, as you FPGA pins go to 3.3V maximum, and they cannot drive large peak currents currents as the one you need to quicky switch a FET.

    I also used PWM to drive a motor before, but more as a hobby project. There are in fact actual PWM H-bridge ICs, see e.g. this one: http://www.ti.com/product/l293 (http://www.ti.com/product/l293), which I would recommend for your application.

    I would also add a capacitor in parallel to the motor, to provide a path to the motor's coil current when the PWM is in idle phase, as seen e.g. here: http://www.ermicro.com/blog/?p=706 (http://www.ermicro.com/blog/?p=706). I'm not an expert either, so if you want to make a real product out of this, you should read some more about that topic. For a hobbyist project, however, just using a controller chip with the datasheet's recommended circuit should be enough.

    Best regards,

    GooGooCluster
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    To add to the chips, there are some driver boards that take input from a controler and they have outputs that drive the motor. Any capacitors etc. are already on the board, this makes controig them much easier.