PA control, protection and monitoring using 16c57+/16f84

Find out how to setup your programmer's software and how to solve many common problems.

Moderator: phalanx

Post Reply
Posts: 1
Joined: Wed May 14, 2014 6:02 am

PA control, protection and monitoring using 16c57+/16f84

Post by brlmat » Wed May 14, 2014 11:53 am

Hello everybody!

First of all, I want to warn you that I am a complete beginner in writing code for pic. I am currently studying a book on writing code in c.

I have two pics laying around: PIC16C57 and PIC16F84A and I want to use them in a power amplifier controlling, protection and monitoring kit. The whole kit will show it's and the poweramp's status on a 7" LCD screen (accepts both PAL/NTSC).

What I want to achieve with this:

1. Softstart. Basically coupling relay_1 1 second after AC sense. (one digital out pin normally low. high after the 1 second)

2. Power-on mute. Relay_2_left and relay_2_right couple 5 seconds after AC sense. (two digital out pins normally low. high after the 5 seconds)

3. DC Protection. If DC_sense_pin_left/right goes high then relay_2_left/right decouples and display shows DC ON LEFT OUT! or DC ON RIGHT OUT!. (two digital in pins)

4. Current monitoring and overcurrent protection. 0-15 amps mean 0-5v on I_sense_pin_left/right. This reading is peak current. If over 10 amps for more than 0.3s then relay_2_left/right decouples and shows OVERCURRENT! on display. Also, the instantaneous value will always be shown like Current left:5.03A Current right:4.87A. (two analog in pins)

5. AC voltage monitoring. This in mainly rectified and unfiltered AC downscaled with resistors to match the max voltage on pic pin of 5v so the pic sees half a sinusoid every 20ms. If AC voltage falls under 170V then the protection resets (relays 1 and 2-l/r decouple and restart the 1 and 5 seconds timers.) and it writes BROWNOUT! on LCD. If the AC is disconnected then relay 1 and 2-l/r decouple as well as the inputs reset and the LCD writes NO AC!. There will also be a constant reading of the voltage: AC:230VAC and the display would normally show AC OK! . (one analog in pin)

6. Temperature protection and fan control. Two TMP36 (-50*C=0v ... 125*C=1.75V) will do the readings for each channel. The display will continuously show the temperatures: TEMP:56*C. As for the fan, it should start when the temp reaches 50*C at 50% then increase linearly to 100% at 70*C (analog. 50%=2.5v, 100%=5V). If the temperature reaches 85*C then the display will show HIGH TEMP! and at 95*C it decouples the output entirely (relay_2_left/right) showing OVERTEMP!. If the temp reaches 100*C after decoupling the speakers then it's the amplifier's fault and all power should be cut off and should not recouple only after power cycling. I haven't thought about this until now... I am not sure if i should implement this as it would use 2 big-ass relays per channel that should be able to break an 80V spark at maybe high currents. Maybe a mosfet to do the switching? (two analog in pins + probably 2 digital out pins normally high)

7. Input selection. Momentary switches toggle the active channels. They are normally off but at the first press of the button, the input becomes high (on) and couples a relay. This for 4 inputs. (four digital in pins and 4 digital out pins normally low)

8. ~Power in 8 and 4 ohm loads / speaker. This is basically an approximation based on mean input current (mean value over 1s maybe). The formulae is I^2*4 for power in 4 ohms and I^2*8 for power in 8 ohms. (no supplementary pins).

+ Displaying all the info (2 digital out pins).

Now that I have bored you to death, here comes my question:

Can I do all of this in realtime with instant reaction with my two antique microcontrollers, PIC16F84A and PIC16C57 ? If not, which cheap microcontroller could I get? For the video part, that doesn't need to be realtime, 0.5-1s delay between action and display is completely acceptable. I could also source some ram chips for use with the microcontrollers if it's necessary.

Applied power should be no problem as i will be regulating from 22V DC with a LM317 and filtering with a big 6800uf capacitor which would provide power to the microcontroller for a lot of time after power loss. Same for display.

If it can be done, would somebody be kind enough to guide me through the project? At least in big lines. I have yet to think the algorithm. Could someone help me with the flow diagram?

Also, for displaying info I have found a library that can generate PAL signal. ... pic-pal-tv

I attached a sketch of the amplifier's face so you could see how i want my data organised. The screen is 16:9 but it can take 4:3 info and widen it so it fits.

Thank you a lot! And I hope I didn't bore you, neither did I post in the wrong section.

User avatar
Non-SFE Guru
Posts: 1991
Joined: Sun Nov 30, 2003 8:57 am
Location: Candia, NH

Re: PA control, protection and monitoring using 16c57+/16f84

Post by phalanx » Tue May 20, 2014 6:17 am

What you are looking to do is outside the realm of the obsolete 16F84 part. The 16C variant is a one time programmable part which isn't too helpful for development purposes.

Some of the functionality would be well suited for the 16F84 such as the soft-start, power-on mute, and input selection. These functions alone could eat up 11 of your 13 available I/O pins.

Temperature sensing could be done by using digital 1 wire sensors and fan speed control could be performed as well (requires external transistors). Multiple 1 wire devices can share a single pin but each fan speed output would require its own pin which puts us over our total pin count.

The DC protection could also be performed by the PIC so long as your DC sense circuitry provides a digital signal output since this PIC doesn't have analog to digital conversion capabilities. Along the same lines, current and voltage protection could be done so long as an external circuit is doing the measurement and providing a digital signal to the PIC.

The sampling of analog values like actual current or voltage levels isn't possible without an external A/D converter of some flavor. At this point you don't have the I/O pins to implement one.

The NTSC/PAL LCD screen you have can't be driven by the PIC either. PICs simply aren't designed to generate those types of waveforms. What you would need is a character LCD that can be connected digitally. While you can find ones here on Sparkfun with a serial backpack, you still don't have enough pins to drive it with the other functionality you want.

Other areas of concern are interfacing with mains voltage. If you don't know what you're doing, this can be a very dangerous proposition.

Nothing that you are trying to do (save for driving a NTSC/PAL LCD) is too difficult but you have to spend the time designing the analog front ends, determine all the pins you will need from a microcontroller, and then select a part that has the right combination of processing power, I/O pins, and memory to get the job done.


Post Reply