I am an arduino rookie and definitely not an expert in electronics, even if I do know the physics that is behind it. Before burning my object of experience, I prefer to ask my silly question to the community.

Context :

  • I do use a bare stm32 based Nucleo L053R8 board which is arduino compatible.
  • I want a 1 minute long loop during which I send a 1.5V@20mA impulsion during 1 second and a -1.5V@20mA impulsion 30 seconds later.

Question :

  • can I simply use and wire two arduino PWM-able pins only to implement that alternating polarity low current? Or will it fail because of unsinked current?
  • A Nucleo board is not considered an "Arduino" within the meaning of this site - some of them have a physically compatible shield connector, but unless you are running fairly unsupported 3rd party software that you have neglected to mention, they are not software compatible with Arduino, which means your question is not on topic here. Typically the native development environment for a Nucleo is mbed. – Chris Stratton May 16 '16 at 19:53
  • I agree. My Nucleo board is not a real Arduino board, not even fully compatible. By the way, my board has a physically similar shield connector. And yes, I do use mbed. – William Gacquer May 17 '16 at 20:32

It's quite hard to understand what you want from your question, it's quite "woolly".

However, I will note:

  1. It's not possible to output a negative voltage from a normal microcontroller.
  2. Getting a specific voltage (accurately) from PWM requires good filter design and a feedback system to keep the voltage within bounds.

I say it's not possible to output a negative voltage - that is with respect to ground. Depending on what you are feeding this voltage into you may not need to reference to ground. In this case it is possible to reference the voltage to another IO pin (steady state, output, not PWM). With it set HIGH the PWM pin's filtered voltage will be below that IO pin's voltage and thus appear, with respect to that IO pin, to be negative. With the IO pin LOW it will appear, with respect to that IO pin, to be positive.

Once you have filtered your PWM signal you will need the output voltage from it to be monitored by an analog input. That can measure the voltage and make sure that your PWM is set to the right duty cycle. Note that the required duty cycle for any one specific voltage will depend largely on the filtering and the load on the output at the time. You will most likely need some form of PID algorithm to constantly adjust the PWM duty cycle. Also remember that your measured voltage will always be with respect to groud, so you will need to subtract your output reference voltage (the output state of your reference IO pin - high or low) from your measured voltage to get the voltage as seen with respect to the IO pin.

  • The last 2 sentences in the 2nd paragraph are unclear and incomplete, i think: "With the IO pin (LOW?), it will appear..." – SoreDakeNoKoto May 16 '16 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.