DATA CONVERSIONS WITH PIC 12F1822

For general Flowcode discussion that does not belong in the other sections.
Post Reply
SILVESTROS
Posts: 118
http://meble-kuchenne.info.pl
Joined: Tue Dec 13, 2022 9:04 pm
Has thanked: 31 times
Been thanked: 2 times

DATA CONVERSIONS WITH PIC 12F1822

Post 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

medelec35
Matrix Staff
Posts: 1660
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 581 times
Been thanked: 554 times

Re: DATA CONVERSIONS WITH PIC 12F1822

Post 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.
Martin

chipfryer27
Valued Contributor
Posts: 1367
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 330 times
Been thanked: 475 times

Re: DATA CONVERSIONS WITH PIC 12F1822

Post 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

SILVESTROS
Posts: 118
Joined: Tue Dec 13, 2022 9:04 pm
Has thanked: 31 times
Been thanked: 2 times

Re: DATA CONVERSIONS WITH PIC 12F1822

Post 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

chipfryer27
Valued Contributor
Posts: 1367
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 330 times
Been thanked: 475 times

Re: DATA CONVERSIONS WITH PIC 12F1822

Post 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

SILVESTROS
Posts: 118
Joined: Tue Dec 13, 2022 9:04 pm
Has thanked: 31 times
Been thanked: 2 times

Re: DATA CONVERSIONS WITH PIC 12F1822

Post 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
Attachments
W_FSR_RECEIVER.fcfx
(11.43 KiB) Downloaded 230 times
W_FSR_SENDER.fcfx
(12.62 KiB) Downloaded 223 times

chipfryer27
Valued Contributor
Posts: 1367
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 330 times
Been thanked: 475 times

Re: DATA CONVERSIONS WITH PIC 12F1822

Post 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

SILVESTROS
Posts: 118
Joined: Tue Dec 13, 2022 9:04 pm
Has thanked: 31 times
Been thanked: 2 times

Re: DATA CONVERSIONS WITH PIC 12F1822

Post by SILVESTROS »

Hi

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

Regards

Basil

Post Reply