CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC12F675 ADC setup
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
temtronic



Joined: 01 Jul 2010
Posts: 9632
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Oct 01, 2016 5:08 am     Reply with quote

I agree with Guy ! After 20+ years with just PICs, they STILL surprise me how well they can do complicated tasks, easily, with some CCS C code. Over the years I found out it was best to use just 2 PICs. An 18 pin device,like the 16F628A and a 40 pinner, the 18F46K22. I use a PICkit3 as the programmer. These days I normally just use the 46k22 for all projects. Yes, way more 'powerful' for simple projects but it has lots of memory, fast (64MHZ, internal too !), 2 HW UARTS, 2 HW I2C/SPI, timers, etc. It runs off 3 AND 5 volts so NO problems interfacing to 3 volt devices like GPS, SD cards,etc.
By using just the 46k22, I have developed a 'library' of good,solid working code (functions). There's no need to buy the 'new PIC on the shelf' that usually has 'something' funny about it (opposite defaults,pin layout, etc) or that the compiler doesn't fully understand (pin names, default, bug).
While you probably don't consider your TIME as a cost,in business 'time is money'. By using a more powerful PIC, the project can be completed faster and has the option to add the extra LED the client wants or bigger LCD, GPS, etc. The 'upfront' extra cost for the bigger PIC can be cheaper than the R&D costs of a smaller PIC, especially when you try to recode to get just one more I/O pin or 4 extra bytes for that new function...
The 12F675 is a nice 'little PIC' and I've made a few items with it but you'll quickly run out of I/O or memory.
Also, NO 'simulator' actually simulates the real World! I could write a book on how bad they are but....just consider analog noise or EMI. None will tell you the 'numbers are off' because the cellphone ringing on the next bench IS sending noise to the wire on the sensor to the PIC...
just some points to consider.


Jay
Arakel



Joined: 06 Aug 2016
Posts: 107
Location: Moscow

View user's profile Send private message Visit poster's website AIM Address

Thank you for the reply!
PostPosted: Sun Oct 02, 2016 9:49 am     Reply with quote

Thank you for the reply!

The suggestion towards me was: "get one microprocessor and learn it". I chose PIC because it is much easier than DSP TigerShark. I realise that PIC18 or PIC24 would be better but like I said this is for educational purposes. With a small PIC I can learn the details and plug the wholes in my knowledge little by little. It has a few pins so there is little chance for mistakes (the problem is easier to find) and I have to code everything in detail which teaches me more. Since I make the portions of the code by little I understand the PIC architecture better and easier plus the coding is smaller and easier to understand.

I also decided that starting with PIC16 is not good for me because it is with too many PINs, interfaces and so on... which makes it more difficult to remember and more mistakes to find out from where do they originate. I have been programming DSP- synthesizing signals, Fourie discreet transformation, visualize 3D signals.

As for the simulator, I would be happy to buy a PIC with PIC board, I thought that it would be good to first make some simple device like a temperature measuring device and than buy the elements.

You are right about the hysteresis (it would be easy to make the temperature within some range with a Trigger of Schmitt, but that means it will not be calibratable). I thought very little about this and so far the only hysteresis that I made is: "potentiometer < sensor" instead of "potentiometer <= sensor". What you said about the noise is extremely right and brings questions that I have to answer. Normally for biomedical electronics a 0.001V signal can become 2V because of all the interference, that is why we use schematics with OP amplifiers to reduce the noise and sine phase signals.

I am sorry but I will continue with PIC12 at least for a little while. After which I intend to pass on PIC16. So far it has thought me a lot. I will deal with the timers on PIC12 and background process timing plus unions and macros while the code is still simpler and smaller. After that I intend to pass on PIC16. If you want give me an email and I will send you what I have done so far.
_________________
Yo! I love learning and technology! I just do not have experience so do not be angry if I ask a stupid question about a detail! From so much to remember sometimes I forget the details in order to remember the big problems!
Ttelmah



Joined: 11 Mar 2010
Posts: 20059

View user's profile Send private message

PostPosted: Mon Oct 03, 2016 3:14 am     Reply with quote

Remember 'having pins', doesn't mean you have to use them.
However the PIC 12's are so small that basic things end up using all the pins, or getting more difficult. One of the most useful things to start with is driving a basic text mode LCD, and you need a minimum of six pins to do this. Since a PIC12 only has five output pins it gets more complex and you end up actually making things harder.
A basic 20pin, or 28pin PIC is the really best starting place.

On your size PIC, the best starting point, is actually a device like the PIC12F1840. Reason is that this has hardware serial. With this, as an alternative to the LCD, you can use the two serial pins, and talk to a terminal program.

Going small does not make things easier. It's a bit like starting on watch repair, rather than trying clock repair, and then learning to do the smaller detail work on watches....

There are other reasons too. For small signals, you have to understand that 'processing' always functions better, the cleaner the signals are to begin with. Now on the larger PIC's you have the ability to feed both Vref- and Vref+ from external pins. You can build a carefully designed analog processing circuit to amplify your signal, and feed it into your ADC pin, with a carefully laid out ground plane, that is common to the Vref- pin. Then feed this into the PIC, with a separate external Vref on Vref+ (typically at 2.5v, since this is usually the minimum range over which the ADC gives it's full resolution - depends on the chip). Done carefully, you can get signals that give you +/- 1 count even with 12bit ADC's. With the PIC12, you only have the option to use the Vref+, and lose another pin to do so.

You can add hysteresis as a percentage of the selected calibration range. However you start running into the code getting larger, and this again is where the PIC12's fall down.

The PIC 12's are great little 'glue' PIC's. They are not good PIC's for any significant project.
Arakel



Joined: 06 Aug 2016
Posts: 107
Location: Moscow

View user's profile Send private message Visit poster's website AIM Address

PostPosted: Wed Oct 05, 2016 12:16 pm     Reply with quote

I guess I will be passing on PIC16 soon.
_________________
Yo! I love learning and technology! I just do not have experience so do not be angry if I ask a stupid question about a detail! From so much to remember sometimes I forget the details in order to remember the big problems!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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