PIC18F25K22 UART ERROR

For general Flowcode discussion that does not belong in the other sections.
mnfisher
Valued Contributor
Posts: 953
http://meble-kuchenne.info.pl
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 507 times

Re: PIC18F25K22 UART ERROR

Post by mnfisher »

Just done a quick test with esp32 and ToString$(.x) takes about 2uS for .x = 1234.

Did you mean FloatToString$ - this took ~8uS (this on an esp32?)

If you are using something slower - say an Arduino - then if you want to use floats then multiply by 100 (10 / 1000 depending how many digits accuracy) and use ToString$ (avoid fp arithmetic)b Use the least number of digits (and smallest variable type) that you can get away with.

Writing my own fixed number of digits ToStr - takes 830nS for 4 digits
tostr.fcfx
(9.51 KiB) Downloaded 11 times
Martin

chipfryer27
Valued Contributor
Posts: 1147
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 284 times
Been thanked: 412 times

Re: PIC18F25K22 UART ERROR

Post by chipfryer27 »

Hi

Very helpful info.

I think the only sensor that used floating point was the 6050 and it may be possible to use integers, or at least limit the decimal places for those readings.

Even with the PIC running a lot slower than the ESP, the mS results do at first look seem quite odd.

Regards

SILVESTROS
Posts: 90
Joined: Tue Dec 13, 2022 9:04 pm
Has thanked: 24 times
Been thanked: 1 time

Re: PIC18F25K22 UART ERROR

Post by SILVESTROS »

chipfryer27 wrote:
Sun Mar 03, 2024 7:50 am
Hi

Floating point calculations can be quite resource heavy on an 8-bit. The 25K22 has an internal oscillator that runs at 16MHz and you can also use the 4 x PLL to up the speed to 64MHz, thereby improving speed by a factor of four.

The peripherals will still take time to obtain data, but at least calculations etc will improve.

Regards
Hi
I use 4xPLL to up the speed to 64MHz, so the frequency of iteration at Send Loop is now about 70/sec, near to my goal...I would like to know what is the frequency of sending Data( MMA8452 + MAX30100 ) from receiver to UART..How can i measure that in receiver ?
Regards

chipfryer27
Valued Contributor
Posts: 1147
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 284 times
Been thanked: 412 times

Re: PIC18F25K22 UART ERROR

Post by chipfryer27 »

Hi

First I'd follow Martins's suggestion (as always) regarding the calculations. Do you really need (for example) 123.xyz if 123.x could do instead? Reducing these times will result in significant savings.

Increase comms speeds to all sensors / modules to maximum that allows reliable communications (400KHz / 115200 baud).

The time to actually transmit between devices is unfortunately out of your control as that relies on the connecting infrastructure (e.g. your WiFi router and how "busy" it is), However if on your WiFi LAN you can measure this. On your Tx device set a pin just before you transmit. On your Rx decice set a pin as first action in your Rx Interrupt routine. Trigger a scope / analyser on Tx and measure between pins.

Sorry to be brief.

Regards

Post Reply