Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Overspeed Shutdown controller

Status
Not open for further replies.

JayArr

New Member
Hi All

I'm new and I am reading the tutorials but I would like confirmation that the assumptions I'm making are correct.

I've read that I should replace the old 16C54C with a 16F54, that makes sense. Correct?

Pinouts are the same so when I get the 16F54 working it will drop in to replace a dead 16C54C without having to change any components on the circuit board. Correct? (I want to be able to repair old circuit boards as well as build new ones.)

I assume that I need to write a new source code file for the 16F54, Correct?

The project is a circuit board that reads the RPM of a generator using a hall effect sensor located beside the generator output shaft. Input on RB3. When RPM exceeds 660 RA2 goes high turning transistor Q1 and subsequently relay K1 on (this shuts off the starter motor). If the RPM ever exceeds 2190 RA1 goes high turning transistor Q2 and subsequently relay K2 on (this shuts down the generator due to overspeed - it should run around 1750-1800).

I've designed the circuit board using ExpressPCB and I've purchased the parts, I own a PICKit2 programmer and have the software installed and working. I have downloaded and installed MPLAB which resulted in icons for IDE, IPE and "driver switcher" on my desktop.

I think I'm ready to start coding, have I missed anything?

BTW, I've been playing with code for 40 years so I'm familiar with lower level lnaguages but a bit rusty, last assembly code I wrote was for the Z80 and 6502 CPUs in the 80s. :)
 
Last edited:
I notcice now that you have now edited your post to say which PIC you are talking about.
I have never used a PIC16C54C or PIIC16F54 but Microchip have documentation on migration from older devices. This is a link to one of these documents for this migration. I would try assembling the original source code (With the list and #include lines changed for the F type PIC.) If it assembles without a problem I think it will probably work.

Les.
 
The two are very similar and differ in programming method, not code as Les says. The migration document does say there may be slight differences in behavior (https://ww1.microchip.com/downloads/en/DeviceDoc/41220a.pdf ). Do you have the source code to review?

One thing to be aware of is that the 16C54 was likely programmed stand-alone in a socket. If you do that with the 16F54, no problem. If you use the in circuit programming feature (ICSP), you need to check what is attached to those programming pins, namely Pin 12 (RB6) and pin 13 (RB7) which are ICSP Clock and ISCP Data, respectively.

John
 
Thanks Les and John

I guess I should have been more specific. I don't have the source code, I don't know if anyone does, this is for a vintage piece of equipment that is now obsolete and no longer available, the company that made it has been bought and merged a few times over the years. :(

I have read the datasheets for both PICs and I also read the migration sheet, it mentioned that the copy protect bits from the 16C54 were reduced to a single bit in the 16F54 and moved to a different location but otherwise it's all the same. I thought briefly about reading the 16C54 with my old Stager G540programmer and then writing the file to the 16F54 with my newer PIC2 programmer but I think my odds of that working are slim to none. One area of concern is the oscillator, will the new 16F54 work with the same old 8MHz resonator that ran the 16C54, this is pretty important for 'drop-in' replacement repairs, I guess I'll find out once I've got some code written.

I don't plan to use the ISCP for this design, it's great and I've used it before but it doesn't present an advantage here so I'll program in-socket before soldering the IC into the board (I'll test in a socketed prototype board first)

JayArr
 
The 16C54C is still available from DigiKey for less than $2. Assuming you can read the old chip, why change?

Never mind. Just reread your original post. I guess you have read the older chip.

John
 
Yeah, no source code, so if I have to write it I may as well write it for the 16F54.

Any thoughts on counting methods for a tach?

The circuit doesn't use TOCKI to count the pulses, it uses RB3. I don't know why they didn't use TOCKI but I have to follow their design.

I'm trying to determine if I should:

A) count the time it takes between pulses.

or

B) Count the number of pulses in a set amount of time, ie how many pulses in 1 second.

Operating RPM is from 0-2190RPM, the first action point is at 660RPM, if the pulse is a 5% duty cycle at 660 RPM the pulse will be about 4.5ms. At 2190RPM the pulse will be about 1.4ms, I think both should be a healthy enough pulse for the PIC to count.

I'm leaning toward amount of time it takes between pulses, at 660RPM that'll give me a reading every 90 miliseconds and at 2190 it'll give a decision point every 27 miliseconds. (output 1 turns on at 660, output 2 turns on at 2190)

JayArr
 
I would also lean toward counting the time between pulses. If you clock the timer from a 32.768 kHz crystal, your 90 ms would be about 30,000 counts. The 8-bit timer and prescale give you 65,536 counts. If you want to time the highs, a faster clock would give the same resolution, i.e., 7 or 8-bit.

Counting pulses for fixed periods will give slower response, since the periods would have to be quite long to get that same resolution. 2190 rpm is only 36.5 Hz, assuming 1 pulse per revolution, or about 5 or maybe 6-bit if you count for > 1 second.

John
 
I am not very conversant with some of the "pin compatible" 16Fxx or 16Fxxx chips. But, if you are writing code, the 16F84 will give you an interrupt in an 18-pin compatible package, and you get a couple of added instructions to help with the math. Also the 16F628A. There are probably even newer more capable chips with the same pin layout.

Is your chip the 18-pin PDIP?

John
 
I agree with John that counting the time between pulses is a better solution. (I am assuming the hall sensor gives one pulse per revolution. You have not actually said how many pulses per revolution it gives.) I have also been assuming that you had the source code and .hex file for the PIC16C54. I have code to run on a PIC16F628A for two tachometers if you want to see examples of measuring the tilme between pulses. They are much more complicated than the code you would neeed as they include maths routines (Copied from a Microsoft application note.) and also have code to drive a multiplexed 7 segment display. You would not need to convert the time between pulses to RPM. You could just compare the time between pulses with values coresponding to 660 RPM and 2190 RPM.

Les.
 
I just tried a quick parametric search of Microchip for 8-bit, 18-pin chips. List is not that large, if you eliminate the 18F results:
upload_2017-8-11_14-26-30.png


Here's a link to the search page: https://www.microchip.com/ParamChartSearch/chart.aspx?branchID=1005

If you go with any of the newer chips, you will get a CCP (compare/capture/PWM) module that makes timings like we have mentioned really easy. You just let the timer run and do a simple subtraction for the duration. Latency is negligible. For simplicity and Assembly language, I would stick with the 16F versions.

John
 
OK, the programming gods just smiled on me! :)

I took a cheap G540 programmer I bought for less than $50 on eBay and read the 16C54C then pulled it out of the socket and dropped in the 16F54 and hit program and it worked. Straight hex code from one to the other and it's operational. I wouldn't have bet a dollar on that working but my problem is solved, I don't have to re-write anything. I still don't have a source code file but for the purpose of repairing and building these circuits I don't actually need one.

I'm a little disappointed I don't get to learn more about how MPLAB X works but I'm sure there will be opportunities in the future.

Thanks to all who helped with this project.

For anyone searching in the future - the PIC16F54 seems to be a drop in replacement for the PIC16C54C, code and all.

If you want to migrate buy a G540 programmer from eBay, it seems to be one of the few programmers that will program both the 16C54C and the 16F54.


JayArr
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top