Jump to content

Low power Geiger counter with MSP430G2553 (Last updated: May 07, 2015)

Recommended Posts

Use long int (or long unsigned) and use `ld'  (lowercase ell d )instead of `d' in the format string for sprintf. `d' is standart int. `ld' is long int.



The only info sprintf has about the type is from the format string, so if you spec standard int, whatever the param is, even if it is a long, will be interpreted as a standard int.

Link to post
Share on other sites

Ah right, agreed, didn't fully read the first post :D


I think %lu may work too for going up to ~4 billion with unsigned long's.

Thanks, you are right, it goes up to 2^32 ? 1, whereas ld doesn't.

void loop() {
Link to post
Share on other sites

don' bother float.... If the value won't overflow (less than about 650*10^6 decimal), mult by 3 than divide by 100. The mult by three can be done as `(i<<1)+i'. This will give an int value truncated.



You can avoid the div by 100 completely. After the sprintf, insert a decimal point before the last two digits. This requires that the value is >= 100 decimal, or there won't BE anything before the last two digits. This can be handled by forcing leading zeroes for 3 dig if value is <100 (using a condition and two sprintf's... one for each case)

Link to post
Share on other sites


Hi all,


2. Problem: how to convert an number into a float point number, e.g. if I want to multiply counts variable by 0.03 and display it?



I take it the built-in sprintf doesn't handle floats?

If want to do it without using floats - could do something like:

unsigned long long count3 = 3 * counts;
sprintf(string,"%lu", (unsigned long)(count3/100) );
add code to print the decimal point in the right position
sprintf(string,"%u", (unsigned) (count3 % 100));
print this in the appropriate location

That is just the skeleton - would have to fill in the printing code (and conditionals to handle 0 fractional part, etc.)

Link to post
Share on other sites
  • 4 months later...

The compensation function works fine :) Thank you for sharing it.

407387 CPM its non compensated value triggered by several Am-241 pieces placed on SBT-11 mica window, see the photos. The software displays compensated dose rate of 8.00mSv/h with 190uS dead time and 0.0057 conversion fator.


Thanks :)

I'm not sure but I think compensating 407387 CPM with 190

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...