Hi All
I have built a data logger type of “Black Box” to be installed on a boat.
I’m using a BL4S200 in a waterproof housing,
We want to record wind speed and I have modified a standard wind instrument so that I can get a raw signal from the anomemeter. This signal is a square wave, 2 pulses per revolution. It is 50 % duty cycle pulse, with the frequency increasing with wind speed. So low wind speeds the frequency on only a few Hz, and a few hundred Hz at high wind speeds.
I have tried getBegin() and getEnd() functions, using DIO1, but not having much success.
I looked at the sample IC_Test.C but could not figure out how to access PC5 as on the BL4S200 this port/bit seems to go to the RIO chip.
The following code is what I created to test capturing a 50% duty square wave from DIO1 (taken from the sample file pulse_capture.c as found in the BlxS200/DIO directory
I’m not a great programmer, more of a technican. But struggling through Dynamic C.
Any advise appreciated
/******************************************
This sample program was created from code within
samples/blxs200/DIO/pulse_capture.c
*********************************************/
#class auto
#use "BLxS2xx.lib"
#define USE_PRESCALE BL_PRESCALE
// set the STDIO cursor location and display a string
void DispStr(int x, int y, char *s)
{
x += 0x20;
y += 0x20;
printf ("\x1B=%c%c%s", x, y, s);
}
void main()
{
int i;
word begin;
word end;
char pulse_width[80];
// Initialize the controller
brdInit();
// Setup input capture for begin=rise & end=fall on the same channel
setCapture(1, BL_CNT_RUN, BL_EVENT_RISE,
BL_SAME_CHANNEL | BL_EVENT_FALL | USE_PRESCALE);
i = 0;
while (i < 10000)
{
resetCounter(1);
getBegin(1, &(begin));
getEnd(1, &(end));
// Display current captured begin and end values from pulses
sprintf(pulse_width,"%d, Ch. 0 Begin = %u, End = %u, Diff = %u
",
i,
begin,
end,
(begin - end)
);
DispStr(1,2,(pulse_width));
i = i+1;
}
}