Page 1 of 1

RF Detector

Posted: Mon Jun 02, 2014 10:44 am
by don854
Hello all,

I have constructed a project which converts the DC voltage from a RF detector circuit to ADC counts using a PIC16F876 and displays the counts as RF power in -dBm and a Bar graph representing signal strength on a LCD. Initially in the calculator block I just put in simple calculations such as RFPower=(ADCReading -1023)*45/716 and Bars=45/(0-RFPower) whilst I completed the rest of the project. Once all finished I calculated a equation from the plot of RF power vs counts and came up with RFPower=(ADCReading*0.0571-83.2972), Bars=400/(0-RFPower). With these equations placed in the calculator block simulation worked fine but when the micro was programmed the RF detector stopped working all the LCD display did was stay on one number and not display any bars, number was random any help greatly appreciated. Also I admit I did plagiarise the Bar graph program.

Regards,

Don :oops:

Re: RF Detector

Posted: Mon Jun 02, 2014 1:29 pm
by medelec35
Hi Don,
Welcome to Matrix forums.

It's always helps if you can post a flowchart, and let us know what version of flowcode you have got (Help, About Flowcode)
If it's commercially sensitive then someone may be able to PM you about that.
don854 wrote: Also I admit I did plagiarise the Bar graph program.
If it is from a flowchart that I had posted then I don't mind at all!

Martin

Re: RF Detector

Posted: Mon Jun 02, 2014 6:30 pm
by JohnCrow
Hi Don
Sounds an interesting project.
What hardware are you using for the RF detector?

Re: RF Detector

Posted: Tue Jun 03, 2014 9:51 am
by don854
Apologies couldn't figure out how to attach the flowchart. I'm using Flowcode 4.5. Hardware used is the following;
Gali-39 RF Amp
MAX4003 RF Detector
LM358 Signal conditioning-Peak detector and non-inverting amp
MCP73831 LI-ION Battery Charger and
Pololu U3V12F9 DC/DC converter

The detector is designed as a handheld device that's the reason for the MCP73831 and the DC/DC converter is for the RF circuit.
How do I attach the Flowchart?
Don

Re: RF Detector

Posted: Tue Jun 03, 2014 9:55 am
by don854
medelec35 wrote:Hi Don,
Welcome to Matrix forums.

It's always helps if you can post a flowchart, and let us know what version of flowcode you have got (Help, About Flowcode)
If it's commercially sensitive then someone may be able to PM you about that.
don854 wrote: Also I admit I did plagiarise the Bar graph program.
If it is from a flowchart that I had posted then I don't mind at all!

Martin
Apologies how do you attach the flowchart?

Re: RF Detector

Posted: Tue Jun 03, 2014 10:03 am
by Benj
Hello,

When creating/editing a post there is a tab below the main text entry field which states "Upload Attachment", click on this for options to attach a file to the post.

Re: RF Detector

Posted: Sat Jun 07, 2014 2:48 pm
by don854
I might have confused people with my original post so I will hopefully make my problem more clearer. The flowchart attached is almost similar to the original except for the calculator block which has the equation for counts to RF power this flowchart compiles and simulates ok. But when running on the EB006 and LCD board is stays on a ridiculous number such as 18986dBm no negative sign and will not change when counts are changed including the bar graph, I have tried changing variables to floats string manipulation nothing works when I revert to the original flowchart no problems hardware works fine. So I'm fairly confident in saying the hardware isn't the problem the micro just doesn't like linear equations I'm confused. The original flowchart is very inaccurate more than 20dBm error.

Re: RF Detector

Posted: Sat Jun 07, 2014 5:12 pm
by medelec35
Hi Don.
The problem with your flowchart is with the type of variable you're using for calculations.
for instance an Integer is being used, and they are whole numbers only. You can't use any decimal point as thy will be completely ignored and whole part will be rounded down.
e.g 0.999 * 1023 +10
= 0 * 1023 + 10
=0+10
=10
The range of integer (its a signed integer to be precise) is -32678 to 32767
So with using only whole numbers, you will loosing accuracy.

The only way you can use decimal numbers like 0.999 is by using float variables.
They are not really recommended for the older 16F range pics due to taking up loads of ram and 32bits of rom so you will be running out of memory very quickly.
It not all doom as I have modified your flowchart to work on hardware.
With pot reading 0V then display should show -83.4dBm
With pot reading 5V then display should show -24.8dBm
If you want the range to be different then let me know.

THe other thing to mention is when using integer calculations do not go over the integer range of -32678 to 32767
E.g 1023 * 32 is allowed as that will = 32736
1023 * 33 is not allowed as that will -31777 since the result is larger than the allowed 32767 the number has rolled over.
Hence the random looking numbers you're experiencing

Martin

Re: RF Detector

Posted: Fri Jun 13, 2014 9:03 am
by don854
Thanks medelec35,

My intentions were to make the variables floating it's because I couldn't get the flowchart to work that I used integers for ease. I didn't realise I was going over range, had a feeling it was something simple I'm better with hardware than software. The flowchart worked fine all tested fine.

Cheers Don

Re: RF Detector

Posted: Fri Jun 13, 2014 1:15 pm
by medelec35
Hi Don,
don854 wrote: didn't realise I was going over range
That happens fairly often and can take the more experienced by surprise.
Thanks for updating us as forum users like to find out what the end result was..

Martin