Hi All, I've now installed the PicKitPlus compilor so now it seems that I've eliminated hardware issues....hopefully! I've been using my pc board for my model plane timers for some years with the 16F684 and because they are no longer easily available and Microchip will stop making them, I was told that I should use the 16F18324 with the same smd package. I had the boards made and poulated with the same parts beside the new PIC chip. I knew that I would need to change some of my software because I was using the 684 with a 20 MHz crystal.
I had some help (Thanks Evan) with using the timers which I've now sorted out, but I still need to read pulses from one of the brushless motor wires to keep the rpm in check. This works a treat with the 684 board but with the 18324 board it just will not read these pulses. I therefore made a short test program which once again, works fine on the 684 board, but nothing reads on the 18324 board. Here is my test program:
I looked at the data sheet for both chips and I see that the 18324 has a pull-up resistor on the input that I use to read the motor wire pulses which is input PORTC.5, but I have not enabled it on either chip. I also checked to see the level of the pulses coming into that port and they are identical in size. I clean up the pulses with a low pass filter which includes a small transistor that feed the PIC input.
Is there maybe a config that I need to see, or what am I missing? Thanks.
Keith R
Last edit: Anobium 2023-08-09
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just read up on this in the online help and it says:
ADOff
This command is obsolete. There should be no need to call it. GCBASIC will automatically disable the A/D converter and set all pins to digital mode when starting the program, and after every use of the ReadAD function.
It is recommended that this command be removed from all programs.
Any other ideas? I would really appreciate some help with this please. Thanks in advance.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't know if there's a builtin command in gcb, but you can always write to the ANSELx register.
For example, to set PORTC.5 to digital mode just use 'ANSELC.5 = 0', or to set the entire port to digital use 'ANSELC = 0'.
Leaving a pin in analog mode when you're using it as a digital pin can have R-M-W effects if you do bit operations on port pins, so it's best to set them all to digital mode.
EDIT: nevermind... I don't think this is your issue.
I just checked and gcb sets the pins to digital mode automatically for you as part of INITSYS.
I should have checked that first...
Last edit: Jerry Messina 2023-08-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Jerry. Looks like I need to write a few more test routines to figure this out. Maybe this 18324 needs a higher logic level than the 684. I can't seem to find that in the data sheet. I'll do some more tests today and report back here.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Keith a few questions - I walking through a diagnostic with you.
Does the code above for the old chip compile and work in the current compiler ? This means have you tried the current compiler with that code in the old chip.
Can you please compile the code for the new chip and post the ASM file created to this thread? I want to look at the ASM to check versions etc.
There was a change to the compiler in Oct 2021 to reduce the PULSEOUT by 1us ( as the PULSEOUT was 1us longer than the stated parameter). This should not impact your code but I am sharing this insight.
You should try #chip 16F18324, 32 as the old chip was operating at 20mHz and the new chip at 16mHz. This could help.
There is nothing I am aware of in the config that would impact this.
Looking at the datasheet Table 4-4. I see PORTC.5 ( your RPMIn) is set for PPS RX. This means the PPS is SET on this pin,
So, I used PICINFO to load the datasheet and then PPSTOOL to generate the PPS for the chip/RX port. This was then verified against Table 4-4 ( I would not do any of this stuff normally, I would just use PPSTool and then set to 0x0000. ), Then, I edited the RXPPS assignment to 0x0000 to enable normal operations of the port.pin.
Add this to your program to disable PPS on this pin,
'PPS Tool version: 0.0.6.3// Generated for 16f18326//// Template comment at the start of the config file//#startup InitPPS, 85#define PPSToolPart 16f18326Sub InitPPS'Module: EUSARTRXPPS=0x0000'RC5 > RX cancelledEnd Sub// Template comment at the end of the config file
I hope the issue will be resolved with step #6.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't think that's going to change anything, Evan.
A PPS input assignment shouldn't prevent you from being able to read the state of an input pin.
A PPS output is a different story.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
HI Evan & Jerry, thanks for the input, but I have figured this out my old "analogue" way! I looked at the input to PORTC.5 with my scope, and found that the input pulses from reading the brushless motor wire are just over 2.0 V and it seems that the older PIC's are fine with that level, but this new chip needs at least 2.5 volts. I removed the motor and used a signal generator and lowered the amplitude until it stopped working, and found that the new chip needs at least 0.5 volts more. I changed one of the resistors in my circuit to increase the size of the signal to a better level........which I should have done in the first place I suppose. to give my circuit a bit more leeway to work with a broader range to make sure that it triggers the input.
Anyway, thanks to Evan, I now understand how to use the timers a lot better and this part of my program is working well now. The PicKitPlus program works well on my old Pickit2 programmers so it looks like my setup is good for now. I'll bash on now and see if I can convert my old prgam well enough to avoid a total re-write! Much appreciate your help here.
Keith R
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
...and found that the input pulses from reading the brushless motor wire are just over 2.0 V and it seems that the older PIC's are fine with that level, but this new chip needs at least 2.5 volts.
@Keith,
just fyi... that device has selectable input level settings (INLVLC register), and it defaults to ST levels. See datasheet TABLE 35-4.
You can change it to TTL levels for pin RC5 with 'INLVLC.5 = 0'
In any event, I think increasing the input level is a good thing.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks guys, yes, it sure looks like my circuit was on the edge, so getting a stronger signal is a win-win! The data sheets are "above my pay grade" so I can't appreciate the fine details. Anyway, I don't mind learning and with this forum, it makes it all easier.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi All, I've now installed the PicKitPlus compilor so now it seems that I've eliminated hardware issues....hopefully! I've been using my pc board for my model plane timers for some years with the 16F684 and because they are no longer easily available and Microchip will stop making them, I was told that I should use the 16F18324 with the same smd package. I had the boards made and poulated with the same parts beside the new PIC chip. I knew that I would need to change some of my software because I was using the 684 with a 20 MHz crystal.
I had some help (Thanks Evan) with using the timers which I've now sorted out, but I still need to read pulses from one of the brushless motor wires to keep the rpm in check. This works a treat with the 684 board but with the 18324 board it just will not read these pulses. I therefore made a short test program which once again, works fine on the 684 board, but nothing reads on the 18324 board. Here is my test program:
Last edit: Anobium 2023-08-09
Here is the same program for the 18324:
I looked at the data sheet for both chips and I see that the 18324 has a pull-up resistor on the input that I use to read the motor wire pulses which is input PORTC.5, but I have not enabled it on either chip. I also checked to see the level of the pulses coming into that port and they are identical in size. I clean up the pulses with a low pass filter which includes a small transistor that feed the PIC input.
Is there maybe a config that I need to see, or what am I missing? Thanks.
Keith R
Last edit: Anobium 2023-08-09
on newer chips many pins are both analog and digital, and they default to Analog mode. in that mode input pins always reads as a '0'.
check the datasheet ANSELx registers.
Last edit: Jerry Messina 2023-08-08
OK........so how do set it up in GC Basic to be a digital input?
I just read up on this in the online help and it says:
ADOff
This command is obsolete. There should be no need to call it. GCBASIC will automatically disable the A/D converter and set all pins to digital mode when starting the program, and after every use of the ReadAD function.
It is recommended that this command be removed from all programs.
Any other ideas? I would really appreciate some help with this please. Thanks in advance.
I don't know if there's a builtin command in gcb, but you can always write to the ANSELx register.
For example, to set PORTC.5 to digital mode just use 'ANSELC.5 = 0', or to set the entire port to digital use 'ANSELC = 0'.
Leaving a pin in analog mode when you're using it as a digital pin can have R-M-W effects if you do bit operations on port pins, so it's best to set them all to digital mode.
EDIT: nevermind... I don't think this is your issue.
I just checked and gcb sets the pins to digital mode automatically for you as part of INITSYS.
I should have checked that first...
Last edit: Jerry Messina 2023-08-08
Thanks Jerry. Looks like I need to write a few more test routines to figure this out. Maybe this 18324 needs a higher logic level than the 684. I can't seem to find that in the data sheet. I'll do some more tests today and report back here.
Keith a few questions - I walking through a diagnostic with you.
#chip 16F18324, 32
as the old chip was operating at 20mHz and the new chip at 16mHz. This could help.So, I used PICINFO to load the datasheet and then PPSTOOL to generate the PPS for the chip/RX port. This was then verified against Table 4-4 ( I would not do any of this stuff normally, I would just use PPSTool and then set to 0x0000. ), Then, I edited the RXPPS assignment to 0x0000 to enable normal operations of the port.pin.
Add this to your program to disable PPS on this pin,
I hope the issue will be resolved with step #6.
I don't think that's going to change anything, Evan.
A PPS input assignment shouldn't prevent you from being able to read the state of an input pin.
A PPS output is a different story.
HI Evan & Jerry, thanks for the input, but I have figured this out my old "analogue" way! I looked at the input to PORTC.5 with my scope, and found that the input pulses from reading the brushless motor wire are just over 2.0 V and it seems that the older PIC's are fine with that level, but this new chip needs at least 2.5 volts. I removed the motor and used a signal generator and lowered the amplitude until it stopped working, and found that the new chip needs at least 0.5 volts more. I changed one of the resistors in my circuit to increase the size of the signal to a better level........which I should have done in the first place I suppose. to give my circuit a bit more leeway to work with a broader range to make sure that it triggers the input.
Anyway, thanks to Evan, I now understand how to use the timers a lot better and this part of my program is working well now. The PicKitPlus program works well on my old Pickit2 programmers so it looks like my setup is good for now. I'll bash on now and see if I can convert my old prgam well enough to avoid a total re-write! Much appreciate your help here.
Keith R
Jerry - you correct. I know I just tested on real silicon.
I need all the other questions answering.
Ignore my questions.
You are on the road. Good to hear you have sorted.
As Assie Dave says 'first rule of electronics is to check the voltage(s)'.
@Keith,
just fyi... that device has selectable input level settings (INLVLC register), and it defaults to ST levels. See datasheet TABLE 35-4.
You can change it to TTL levels for pin RC5 with 'INLVLC.5 = 0'
In any event, I think increasing the input level is a good thing.
Thanks guys, yes, it sure looks like my circuit was on the edge, so getting a stronger signal is a win-win! The data sheets are "above my pay grade" so I can't appreciate the fine details. Anyway, I don't mind learning and with this forum, it makes it all easier.