Trouble with NBPKBM MIO board

Discussion to talk about hardware related topics only.
Post Reply
clemieux
Posts: 9
Joined: Sun Jun 29, 2008 7:35 pm

Trouble with NBPKBM MIO board

Post by clemieux »

Folks,

Just wondering who's using this DAQ board. I'm running into an issue that may or may not be an issue, but has me stumped nonetheless.

For now, I'm just trying to read a simple voltage from an AI channel. So here are my steps (not many to list):

(1) Initialize the DAQ for 0-5V input on AI Pin 12

Code: Select all

NBPKBM_J1[12].function( P12_FUNCTION_ADV0_5 );	// -- AI Channel 0
(2) Pull a simple reading from the card:

Code: Select all

float val = NBPKBM_J1[12];
(3) echo that to the serial debugger:

Code: Select all

iprintf("fed back ch0 AI val: %.f\r\n",val);
Seems simple, right? Well, my debugger only wants to spit out:

Code: Select all

fed back ch0 AI val: f
I've tried initializing all channels, I've tried initializing just one. I've tried initializing all and/or just one every time I query the input. All with the same results. I did try this approach:

Code: Select all

char value[VAL_LEN]
snprintf(value,VAL_LEN,"%.2f",NBPKBM_J1[12]);
And the app definitely doesn't like this approach

I suspect I'm doing something fundamentally wrong here - kinda hoping somebody can point out what is probably the obvious.

Thanks!
User avatar
tony
Posts: 49
Joined: Thu Apr 24, 2008 6:05 pm

Re: Trouble with NBPKBM MIO board

Post by tony »

Did you try the sample application (C:\Nburn\examples\pk70\MBladeDemo) that comes with the PK70 development kit? This shows one method to do the ADC conversions. I was able to get this working without any issues. If you do a search in the forum you will find some code that I posted from Paul dealing with the ADC conversions. The PINS class using delay or polling for ADC completion and is VERY slow. The ADC has a pin connected to an interrupt line. Using the interrupt I seem to recall getting 40K samples per second. Using the PINS class I think I was only getting about 1K samples per second.

One note of caution once you do get this working is that the IO code from Netburner is not thread safe. I spent a few hours trying to figure out why one of my apps was hanging using this code. I had two threads that were both using the digital IO pins. Every once in a while they would hang up system. I didn't have time to fix the code so I just used a semaphore to block access to the IO calls.
clemieux
Posts: 9
Joined: Sun Jun 29, 2008 7:35 pm

Re: Trouble with NBPKBM MIO board

Post by clemieux »

I just managed to get it to work, but not quite sure why I have to jump through this hoop to do so:

My first attempt to echo back the value:

Code: Select all

float myVal = NBPKBM_J1[12];
iprintf("fed back ch0 AI val: %.2f\r\n",myVal);
resulted in:

Code: Select all

fed back ch0 AI val: f
My roundabout attempt:

Code: Select all

float myVal = NBPKBM_J1[12];
char value[40];
snprintf(value,40,"%.2f",myVal);
iprintf("fed back ch0 AI val: %s\r\n",value);
CORRECTLY resulted in:

Code: Select all

fed back ch0 AI val: 1.40
Is there something wrong with my original notation? There has to be and I'm either too blind or too sleepy to see what it is. :)
clemieux
Posts: 9
Joined: Sun Jun 29, 2008 7:35 pm

Re: Trouble with NBPKBM MIO board

Post by clemieux »

tony wrote:Did you try the sample application (C:\Nburn\examples\pk70\MBladeDemo) that comes with the PK70 development kit?
Hey Tony - thanks for pointing this out - I feel like a bit of an idiot for not digging this up first. But I did do a search on the text "NBPKBM" on the Wiki section (the one that supposedly details all of the examples) and got no hits. Guess I assumed from there that there were no packaged examples.

I did see your posts and read about your dilemmas. Those issues were so much more beyond the basics of what I'm trying to accomplish - for the time being.

Thanks for the feedback though - I'm digging up that example as we speak.
rmigliac
Posts: 6
Joined: Sun Jun 22, 2008 9:13 am
Location: East Setauket, NY
Contact:

Re: Trouble with NBPKBM MIO board

Post by rmigliac »

iprintf doesn't support float (%f) formating.

I use sprintf to define the string in a buffer first, then print it to the serial port with iprintf.

char buf[80];
sprintf(buf,"fed back ch0 AI val: %.2f\r\n",myVal);
iprintf(buf);

-Rich
User avatar
Mark
Posts: 56
Joined: Mon Sep 22, 2008 6:45 pm
Location: Maryland

Re: Trouble with NBPKBM MIO board

Post by Mark »

To add to Rich's comment you can also use fprintf, or just printf. These tend to "cost" more to use verses the iprintf.

A website that I use quite frequently when writing C/C++ is http://www.cplusplus.com; guess that I missed the boat being a machine language guy, then jumping right into VB & C#.
Post Reply