Digital Fat Calliper Sensor

Status
Not open for further replies.
Hi,

For the fat matrix scale, there consists of 64 thin strips. I found that the distance between 2 strip is 0.78mm. My question is, how should I write the programming code so that the microcontroller can get the distance?
I really need help from you all. Thanks.

Vivian
 
If nRBPU isn't found, try RBPU = 0; it is the top bit in OPTION_REG in any case. The WPUB bits default to 1, so you don't need to worry about them.

The calliper draws an arc with the moving arm; therefore you should get the total angle spanned by the 64 switches and divide by 64. This will be the effective angle per switch.

To calculate the skin thickness you also need the distance from the calliper's rotation point to the end of the arm (that end that touches the skin). You then apply some maths (https://www.mathopenref.com/chord.html) and get the chord length, which is the skin thickness. Use a 64 entry lookup table rather than calculating the values in your code.
 
Hello,

I want to shows the value of age and gender in my LCD. And the user can change the value of age and gender by pressing the tact switch. Can I know how should I program my LCD so that it's value can be adjusted??


Vivian
 
Hi,



I have question about this fat matrix charliplexing. Assume one of the button in D5 is pressed, how the charlieplexing works in order to send the signal to the microcontroller? How the microcontroller know which of the button is pressed??
I really need to know it, please help me..thanks!

Vivian
 
Hi Doug,

For the fat matrix coding that you have wrote, how to make the return value to be displayed on the LCD display?
Please reply me, I really need your help.
Thanks a lot.


Vivian
 
You need to learn how to program in C first.

To display information on the LCD, you will first need to initialise it, then write the numeric data (the value returned from the readCalliper() function converted to ASCII characters). Hopefully someone can provide you with direction in this regard.
 



This is the editted code. But I failed to show which button has been pressed.
 
It's good to see that you have access to an LCD library. In https://www.mikroe.com/download/eng/documents/compilers/mikroc/pro/pic/help/lcd_library.htm, they make sure to configure all analogue pins (e.g. comparator and ADC) as digital - make sure to do that for all the pins you are using for the matrix and for the LCD.

To display the caliper value, I'd perhaps use the following:
Code:
uint_t value = readCalliper();
char valueText[4] = {'0' + (value/100), '0' + ((value / 10) % 10), '0' + (value % 10), 0};
Lc_Out(1,8,valueText);
 
Last edited:
Hi Doug,

I tried to use your code, but it come out with an error, which is 'Const expression expected'.

 
The lines of code I provided would go inside the main() function. I omitted the final zero in the declaration of valueText[] (changed above).

If you still get the same compilation error, then you can use the following in place of the declaration of valueText[].
Code:
char valueText[4];
valueText[0] = '0' + (value/100);
valueText[1] = '0' + ((value / 10) % 10);
valueText[2] = '0' + (value % 10);
valueText[3] = 0;

If you want to continuously display the changing value, you'll have to place the readCalliper() and Lcd_Out() functions in a loop (and include a delay).
 
Hi Doug,

The error 'Const expression expected' is come from the code:
unsigned char value=readCalliper();
Before that you are writing 'uint_t value=readCalliper() ', but it come out with the error ' Undeclared identifier 'uint_t' in expression'.
 
That code would go in the main() function.

uint8_t is the same as unsigned char if #include <stdint.h> is included in the code.
 
Hi Doug,

What is this refer to?
char valueText[4];
valueText[0] = '0' + (value/100);
valueText[1] = '0' + ((value / 10) % 10);
valueText[2] = '0' + (value % 10);
valueText[3] = 0;

The code can be run now. But the number of button pressed does not display out.
Attached pic is the design when perform the simulation
 


This is the code that use to simulate the circuit.
 
Code:
void main()
{

ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;

Lcd_Init();
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,2,"25");
Lcd_Out(1,6,"F");
Lcd_Out(1,13,"BF%");

while(1)
{
   // get new value
   unsigned char value = readCalliper();
   char valueText[4];
   valueText[0] = '0' + (value/100);
   valueText[1] = '0' + ((value / 10) % 10);
   valueText[2] = '0' + (value % 10);
   valueText[3] = 0;

   // display new value
   Lcd_Out(2,2,valueText);

   // throttle update rate to stop the display from blurring
   Delay_ms(100);
}
 
Hi Doug,

Thanks for the edited code. But it still no number of button display when I pressed the button. Will it because there is no power supply to the fat matrix? Or because no output is send to the LCD?
Sorry to disturb.
 
Hi,

Below is my problem:
1) The number of button pressed will recount start from 0 when reached diode 5-8.

Attached is my edited circuit design:


And this is the picture for the problem occured:
Button on diode 1 is pressed:


Button on diode 5 is pressed:

Below is the code I use to run the simulation:
 

Attachments

  • fd.jpg
    47.8 KB · Views: 223
  • jj.jpg
    46.5 KB · Views: 225
Last edited:
Hi Vivian,

Sorry, but I can't run the design you provided as there seems to be limitations in the demo version of Proteus.

I can tell you that the resistors connected to PORTA should be connected to 5V and not to ground as you have done. The direction of the diodes should also be corrected.

I will have a look at the code at a later date to see if there are any obvious bugs in the function I provided.

Cheers,
Doug
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…