Page 1 of 1

DATA CONVERSIONS WITH PIC 12F1822

Posted: Mon Aug 05, 2024 1:36 pm
by SILVESTROS
Hello to all !
I would like to make some data conversions using PIC12F1822 as follows..
1. Analog value to digital using A2(AN2) as A/D input , and A4,A5 as output (RX,TX) to send data to PC ( ANALOG TO UART) , and reverse ( RX-TX to Analog ).
2. I2C to UART, using A1(SCK) , A2(SDA) as I2C data input , and A4,A5 as output (RX,TX) to send data to PC ( I2C TO UART), and reverse ( RX-TX to I2C).
Are there some sample codes for FC10 to help me make above data conversions ?
Thanks in advance,

Basil

Re: DATA CONVERSIONS WITH PIC 12F1822

Posted: Mon Aug 05, 2024 4:26 pm
by medelec35
Hi Basil.
Have you gone through all these examples to see which one would suit you the most?
Once you decide, we can help you further.

Re: DATA CONVERSIONS WITH PIC 12F1822

Posted: Mon Aug 05, 2024 4:47 pm
by chipfryer27
Hi

The DAC on that chip is A0 which is the same as UART Tx.
The SCL is A1 which is the same as UART Rx

Therefore you will need to use software channels which given the limited capacity of the chip may be a struggle, especially as you still need to find a pin for the ADC.

Other than that your concept is quite feasible.

Regards

Re: DATA CONVERSIONS WITH PIC 12F1822

Posted: Tue Aug 06, 2024 10:07 am
by SILVESTROS
Hi

Many thanks for your answer.
I would like to make some tests to transfer data using 2 PIC12F1822 via UART . I have very limited space ,so I select that chip in SOIC-8 .
There are 2 cases..
1. First PIC12F1822 (sender)... An Analog value as input to A2 , output at A4 (TX), A5(RX) ----UART serial line----Second PIC12F1822 (receiver)..A4,A5 connected at serial line , Analog out A2 pin.
2. First PIC12F1822 (sender)...An I2C device connected at A1 ( SCK) , A2 (SDA) , output at A4(TX), A5(RX) ----UART serial line ---- Second PIC12F1822 (receiver)..A4,A5 connected at serial line , out as I2C at A1 (SCK) , A2 (SDA) pins.
The above chip has flexible pins that can be set with software/channel, so i would like to confirm if above pin settings / connections can be realized
Also , an example code for above conversions will be very useful..
Thanks in advance

Basil

Re: DATA CONVERSIONS WITH PIC 12F1822

Posted: Tue Aug 06, 2024 9:58 pm
by chipfryer27
Hi

I would have to double check, but I don't think you can have the DAC (providing an analogue out) on anything other than A0. The UART and I2C can be moved via software.

However that chip is quite modest in capability. It doesn't have a lot of RAM so you may struggle.

The datasheet will conform which pins are used for what.

Regards

Re: DATA CONVERSIONS WITH PIC 12F1822

Posted: Tue Aug 06, 2024 11:08 pm
by SILVESTROS
Hi
thanks for info...as I saw in data sheet of PIC12F1822, DAC out is only pin A0 , so I'll make a modification in wiring.
About Analog - UART bridge and reverse , I made 2 demo in FC for test..I would like to have your opinion .
About I2C - UART bridge, and UART - I2C bridge , for now I haven't found an example , so I'll try to make a demo .
Regards

Basil

Re: DATA CONVERSIONS WITH PIC 12F1822

Posted: Wed Aug 07, 2024 7:22 am
by chipfryer27
Hi

Travelling today so won't have a chance to look at anything.

To test your first option you could use the potentiometer component to read an analogue value and then convert to a string. This can then easily be sent over UART (with any necessary structure).

Similarly, you can receive a value as string, convert and pass to DAC as output.

I2C would be similar and the Wiki has examples of use. Grab your value, convert to string and send out over UART.

Regards

Re: DATA CONVERSIONS WITH PIC 12F1822

Posted: Wed Aug 07, 2024 11:00 am
by SILVESTROS
Hi

thank you and good holidays.
I'll try to make some demos for test.

Regards

Basil