View previous topic :: View next topic |
Author |
Message |
ilker07
Joined: 03 Jun 2022 Posts: 39
|
hb100 doppler |
Posted: Wed Dec 25, 2024 6:31 am |
|
|
Hi everyone I wanna use hb 100 with ccs c but Idon 't know how to get frequency through HB100.Please help.
The code :
#include <18F67K22.h>
#device ADC=12
#use delay(internal=16000000)
#FUSES NOWDT
#FUSES WDT128
#FUSES NOXINST
#FUSES NOBROWNOUT
#FUSES PROTECT
#include <math.h>
#pragma use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, stream=uartScreen, errors)
void main() {
setup_adc_ports(sAN1);
setup_adc(ADC_CLOCK_DIV_32);
set_adc_channel(1);
delay_ms(100);
while (TRUE)
{
unsigned int16 adc=read_adc();
float volt=adc *0.001220703125;
fprintf(uartScreen,"%.3f\n",volt);
delay_ms(1);
}
} |
|
|
ilker07
Joined: 03 Jun 2022 Posts: 39
|
|
Posted: Wed Dec 25, 2024 6:39 am |
|
|
[/b][/url]
if there is nothing it gives aprrox 2-3 volt. if there is any movement it gives between 0 and 4 volt depends on movement.if there is a lot of movement , The signal is getting too frequent. |
|
|
ilker07
Joined: 03 Jun 2022 Posts: 39
|
|
Posted: Wed Dec 25, 2024 6:46 am |
|
|
How can I measure the frequency and magnitude of this signal? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9267 Location: Greensville,Ontario
|
|
Posted: Sun Dec 29, 2024 7:25 am |
|
|
1st... post which HB100 you're using. HB100 is just the sensor, and I assume you bought a 'module', which has a lot of components on it to make it 'computer friendly' ?
2nd, get rid of the #fuse protect ! NOT needed and limits life of PIC.
3rd, Use Google, search for code. You're not the 1st one doing this. probably a lot of Ardunio code, that can be easily translated into CCS C
4th, find proper manuals for the device and check IF it's a 5 volt or 3 volt device !! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19584
|
|
Posted: Sun Dec 29, 2024 10:33 am |
|
|
If you are reading the signal from an HB100, you do not want to be using
the ADC. This is not the right peripheral at all. Will not work at all.
The signal from the sensor needs putting through a circuit to turn it
into a detection pulse.
The actually data sheet has a suitable circuit in it, using 2 LM324 op-amps.
The Arduino code examples use this circuit, and measure the period
between the two digital pulses. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1941 Location: Norman, OK
|
|
|
ilker07
Joined: 03 Jun 2022 Posts: 39
|
|
Posted: Thu Jan 02, 2025 7:01 am |
|
|
Ttelmah wrote: | If you are reading the signal from an HB100, you do not want to be using
the ADC. This is not the right peripheral at all. Will not work at all.
The signal from the sensor needs putting through a circuit to turn it
into a detection pulse.
The actually data sheet has a suitable circuit in it, using 2 LM324 op-amps.
The Arduino code examples use this circuit, and measure the period
between the two digital pulses. |
Yes ,I am aware of Arduino codes but I couldn't do it with CCS C. |
|
|
ilker07
Joined: 03 Jun 2022 Posts: 39
|
|
Posted: Thu Jan 02, 2025 7:03 am |
|
|
I red those 2 notes but I couldn't figure it out with CCS C. |
|
|
ilker07
Joined: 03 Jun 2022 Posts: 39
|
|
Posted: Thu Jan 02, 2025 7:04 am |
|
|
temtronic wrote: | 1st... post which HB100 you're using. HB100 is just the sensor, and I assume you bought a 'module', which has a lot of components on it to make it 'computer friendly' ?
2nd, get rid of the #fuse protect ! NOT needed and limits life of PIC.
3rd, Use Google, search for code. You're not the 1st one doing this. probably a lot of Ardunio code, that can be easily translated into CCS C
4th, find proper manuals for the device and check IF it's a 5 volt or 3 volt device !! |
NO,that can NOT be easily translated into CCS C |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9267 Location: Greensville,Ontario
|
|
Posted: Thu Jan 02, 2025 8:03 am |
|
|
hmm, wonder if one of those 'AI' apps can translate ?
I've never had ANY formal computer training courses on 'C' though I did take COBOL at night school for fun. I've used PCM since V2.534 and while my code ain't 'pretty' it works. Over the years, I've translated several Ardunio programs since 'they' seem to try new modules sooner than CCS guys do.
The actual translating is fairly easy once you understand what both compilers are doing. You simply break it down into smaller parts,see what Ardunio codes, then convert into CCS C. Run a few tests to confirm CCS code does the same, then onto the next ..... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19584
|
|
Posted: Thu Jan 02, 2025 10:04 am |
|
|
Yes, actually the Arduino code _can_ always be easily translated into CCS
C, but usually just by looking at what it does, rather than the instructions
used.
This is the key point. It is the flow chart of the operations, that makes the
key to follow, not the actual code. This is also why usually it is easier to
just started from the manufacturers data sheet. That tells you what the
device expects and usually gives a flow of how things have to be done.
The key here is that the raw device _must_ have the signal processing
done before it's output can be read. This is the circuit in the data sheet.
The output from that circuit is not the waveform that has been posted, but
a simple digital sequence, with the time between the pulses directly related
to the speed. Very easy to read. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9267 Location: Greensville,Ontario
|
|
Posted: Thu Jan 02, 2025 10:14 am |
|
|
also.... once the Ardunio code is compiled, you can look at the listing and SEE the PIC machine code that was generated.
This can be used as a 'reference' when translating into CCS C. |
|
|
|