PWM Modul

Concept

The idea behind the concept is simply the fact, that a adjustable PWM source would be handy. Hence the following definitions have been made:

  • two PWM outputs, able to drive "respectable" loads e.g. power LED
  • easy to control, manually or via PC
  • adjustable frequency in order to drive loads in kHz range as well as servo ESC in ~50Hz frequency
  • optional differentiate between load and bus supply voltage

Hardware

As only a few in/outputs are needed, a controller out of the Tiny25/45/85 family seems to be appropriate. The schematic is shown below.

Besides two PWM outputs on timer OCR0A and OCR0B there are two ADC used:

  1. first one reading a potentiometer for manual adjustment of PWM duty-cycle
  2. combined input for Rx (from PC) as well as reading the switch position
  • For driver transistor any NMOS FET can be used, which is drive able with a logic voltage level of 0 to 5V
  • As Rx is shared in function, a 12k resistor has been placed to separate communication and function selection.
  • The switch needs to be a three position switch, which allows a DPCO position ("nothing selected")
  • For connection to PC via USB I've used an inexpensive CP210x module

Software

The initial SW is written in BASCOM (tried to do in Android-C however it seemed to exceed quite quickly the available flash size), so Version 2 needs ~1.4kB (so a Tiny25 could be used).

For fuses make sure you run at 8MHz internal clock speed

Housing

I wanted to use my Lasercutter therefor I decided to build a plywood box. The box template has been modified according the attached plans and lasered on 4mm thick material. After assembly it looks like as follows

How to use

manual:

place the switcher to load 1 or load 2. Immediately the corresponding output DC will be controlled by the potentiometer. Switching to the other load will keep the first PWM output, will only the active one will be changed by the potentiometer position

remote:

Change the switch to middle position and set up your interface to 9600 Baud

sequence:

  1. send one byte to get the attention (doesn't matter which one)
  2. send one byte command instruction
  3. send one byte data instruction

you have 2 seconds for sending a data byte, otherwise you have to restart the communication

command instruction: allowed characters are

  • "1": change DC of load channel 1
  • "2": change DC of load channel 2
  • "3": set frequency of the PWM signal

data instruction: allowed characters are

  • for command "1" or "2": one byte 0..255 which is setting directly the puls length
  • for command "3": one character "1".."5" (correspond to ASCII 49 to 53) which will change the the Timer0 prescaler by 1,8,64,256,1024 respectively

GUI

The initial version is simply concentrating on the key functions

  1. select the COM-Port which will be used for communicating
  2. with the slider you can simply change the DC of the corresponding channels (immediately effective) or enter a value between 0-255 and press SEND
  3. change the frequency by adapting the divider factor. This number is for the moment (in SW V2) volatile and will be reset after a new start to default of ~60Hz

Software

All Software is uploaded (and kept more or least updated) in GitHub https://github.com/TiSpace/PWMModule