|
|
View previous topic :: View next topic |
Author |
Message |
Frozen01
Joined: 23 Apr 2009 Posts: 32
|
Analog Input Question |
Posted: Wed Aug 17, 2016 1:00 pm |
|
|
I am doing another design that will be using the PIC18F4431 and CCS C Version 5.061, and I have a question about Analog inputs...
Does it matter what ones I use? I need to read 2 voltages, and it looks like I have no spare pins, so before I go too far in the design, I want to make sure what I can't do. Looking at the data sheet it looks like the analog input pins are in groups, and I can only select one pin for each group. Then if I look at the conversion sequences, it seem like it would be wise to one pin on Group A and one on Group B and use conversion in Multi channel sequential mode 1.
Been a while since I have done a PIC design, and this is by far my most complex. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Wed Aug 17, 2016 1:49 pm |
|
|
While I've never used that PIC some general comments...
Which pins you use depends upon your application and requirements.
That PIC has 9 ADC inputs, so in the basic 'read a pin - do something', you can choose any of them. It's when you get into the 'fancy' modes that you have to be very careful esp. if you're using Vref+ and vref- in your design
It's one of those cases where you MUST read, and re-read the datasheet. Draw out what you NEED, find the pins that you MUST use, then see what's left. Be sure to read the 'header' file for the PIC to see what CCS has to say about 'combinations' of ADC 'selections'.
Hopefully others who have used this PIC will reply...
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Wed Aug 17, 2016 2:14 pm |
|
|
The groups only matter if you are going to use high speed continuous auto sampling. Otherwise, don't worry about them.
Honestly, unless you need the special PWM capabilities of this chip, use a different one. This chip has a lot of really nasty errata (UART, I2C/SSP, some basic instructions, the PWM etc. etc..).
Even if you do need the PWM capabilities, look at one of the DSPIC's instead. These can do the rapid sampling using DMA, and are really much more capable.
I spent a lot of time on a couple of projects using these chips, and they are one of my 'least favourite' PIC's. Had to write special routines to actually get some of the peripherals to wake reliably.... |
|
|
gjs_rsdi
Joined: 06 Feb 2006 Posts: 468 Location: Bali
|
|
Posted: Wed Aug 17, 2016 2:18 pm |
|
|
I didn't use this PIC also, but as temtronic said have to read the data sheet very carefully.
By the way, the CCS Wizard let me chose any channel I want and again, have so many choices that need really to understand the data sheet.
Best wishes
Joe |
|
|
Frozen01
Joined: 23 Apr 2009 Posts: 32
|
|
Posted: Wed Aug 17, 2016 5:13 pm |
|
|
Ttelmah wrote: | The groups only matter if you are going to use high speed continuous auto sampling. Otherwise, don't worry about them.
Honestly, unless you need the special PWM capabilities of this chip, use a different one. This chip has a lot of really nasty errata (UART, I2C/SSP, some basic instructions, the PWM etc. etc..).
Even if you do need the PWM capabilities, look at one of the DSPIC's instead. These can do the rapid sampling using DMA, and are really much more capable.
I spent a lot of time on a couple of projects using these chips, and they are one of my 'least favourite' PIC's. Had to write special routines to actually get some of the peripherals to wake reliably.... |
Thanks for the heads up. I was leaning toward this chip because of it Quadrature Encoder Interface, but maybe it is not worth it?
I am open to suggestions...
I need to read an encoder to change the values of a setting and the send that information out an SPI bus. I also have to monitor 2 voltages, monitor the state of 4 momentary pushbuttons to change states/modes adn output to an LCD and some status LCDs. 44-pins of this part are just enough. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Wed Aug 17, 2016 5:25 pm |
|
|
gee 44 pins seems a lot, I've never run out using 40 pin PICs.....
one day though , lol
Re: QEI. In the past I used discrete US Digital LS7266 devices with the PIC16F877. As the LS7266 was designed for Quad encoders ,even at very high speeds it never lost a count. Now if you're only looking at say 16 or 24 PPR encoders ( think volume controls for radios), any PIC will handle that application ! You could even use a 'small' ,cheap PIC instead of the LS7266 if price is critical, just be sure to include YOUR R&D time into the equation !
Options, always have a few....
Jay |
|
|
Frozen01
Joined: 23 Apr 2009 Posts: 32
|
|
Posted: Wed Aug 17, 2016 6:32 pm |
|
|
temtronic wrote: | gee 44 pins seems a lot, I've never run out using 40 pin PICs.....
one day though , lol
Re: QEI. In the past I used discrete US Digital LS7266 devices with the PIC16F877. As the LS7266 was designed for Quad encoders ,even at very high speeds it never lost a count. Now if you're only looking at say 16 or 24 PPR encoders ( think volume controls for radios), any PIC will handle that application ! You could even use a 'small' ,cheap PIC instead of the LS7266 if price is critical, just be sure to include YOUR R&D time into the equation !
Options, always have a few....
Jay |
Well this is my first project that is using an encoder, so I was thinking since the IC handled reading etc. the decoder I would go that route.
Did some more looking into encoders, and it looks like Bourns makes a 512PPR encoder that will work, and it is just a directions and pulse output, much easier to read I think...
Anyway back to the original question, so it looks like since I am just going to periodically read the analog pins, it really should not matter which one I choose.
Any thoughts on the PIC18F67K90? More pins that will give me the ability to also include a serial port output output for debugging since I will have enough pins now. (totally not necessary...lol) Gotta love scope creep just because you can! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Wed Aug 17, 2016 6:43 pm |
|
|
Ok, I love 'overkill' ( 18F46K22 is my goto PIC) but....
from your post...
encoder , 2 pins
ADC, 2 pins
SPI, 3 pins
LCD , 6 pins
4PB, 4 pins
LEDs, ?? pins
so maybe 20-24 pins ? How did you use the other pins?
Jay |
|
|
Frozen01
Joined: 23 Apr 2009 Posts: 32
|
|
Posted: Wed Aug 17, 2016 6:58 pm |
|
|
temtronic wrote: | Ok, I love 'overkill' ( 18F46K22 is my goto PIC) but....
from your post...
encoder , 2 pins
ADC, 2 pins
SPI, 3 pins
LCD , 6 pins
4PB, 4 pins
LEDs, ?? pins
so maybe 20-24 pins ? How did you use the other pins?
Jay |
Power & GND- 4
Osc - 2
Switch - 4
LEDs - 7
PGM/Reset - 4
LCD - 7
Voltage Monitors - 2
Encoder - 3
TX IC Flag & Reset - 2
SPI - 4
No-Connects (IC Package) - 4
43 Pins.. I had a duplicate...
Some of the LEDs can be dropped, so that can be brought down to 5
The different encoder brings that to 2
SPI I can bring to 3
So I am at 39... now in reality the original 44 is really 40 with the 4 no-connects... I may just go with the 40 pin PDIP... way easier to assemble.
I will look at the 46K22...Thanks! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Thu Aug 18, 2016 5:16 am |
|
|
hmm..
You can save another pin by using 6 instead of 7 for the LCD module. 99.99% of users never READ the LCD, so R/W is not required.
You can save 2 pins by using the internal OSCILLATOR of the PIC. At 'room temperature', I can run both UARTS at 38K4 without problems (timing issues). If precise timing is needed I use a 4MHz xtal, leftovers from 16C71 days.
You could save 7 pins by eliminating the LEDs. You do have an LCD display so no 'real' need for LEDs. I now only use 4x20 displays and have a hardware 'cheat' to use them on 3V PICs. The 46K22 is one of the nice PICs that can run at 5 OR 3v at FULL SPEED ! It also has 2 HW UARTS and 2 SPI, lots of timers and tons of memory. IF you run out you've got a HUGE project or a sloppy coder !
Jay |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|