Tom.DeVito 1.4.2011

I2C:

  • Found out that com port was not being initialized properly.  Thought this might be due to cstring not converting to lcpcwstr.  Changed com ports name variable to char[].   This did not convert right either.  wchar_t is the correct type to convert to lcpwstr.  This was not the problem though.
  • For some reason, adding a colon after the COM4 made windows happy.  I don’t think this is always necessary considering it is in none of the examples.  How I figured this out was by adding a GetLastError() after the CreateFile call which gave me the error of 123 or file does not exist.  There were many different solutions to the problem and adding a colon doesn’t always work but this time it did.
  • Still can’t write to the register but at least I have a valid HANDLE now.
  • Figured out what was wrong.  To write to the register you need to send 5 bytes to the controller.
  1. Controller Command: This is different for different IC.  We want to use 0x55 because we want to talk to chips that have a 1byte internal address
  2. Address of the chip: These will be 0x5z. z will depend on how the address pins are set.  If both address pins are set to group 0x58 is what you want to send.
  3. Internal Address bit:  0x00 is what I used,  I believe 0x80 will give you the second register but i am not positive.  You can also mute with this byte again not tested yet.
  4. How many bytes of data will be sent:  In our case this is 1 do 0x01.  This is what I was missing when I tried this before.
  5. Step number you want in hex:  Put in whatever range you want 0-255 decimal in hex form.  It is approximately 40 ohms per step.

The way this looks in c

void changeResistance(){

BYTE sbuf[100];
DWORD n;

hCom = CreateFile( temp, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
//set-up com port settings
if (INVALID_HANDLE_VALUE == hCom)
{
printf(“Error: Could not open the RS232 port!”);
getch();
}

sbuf[0] = 0x55;  //controller command
sbuf[1] = 0x58; //address
sbuf[2] = 0x00; //internal address
sbuf[3] = 0x01; //# of bytes to be sent
sbuf[4] = 0x0A; // steps of resistance
WriteFile(hCom, &sbuf, 5, &n, NULL);
ReadFile(hCom, &sbuf, 1, &n, NULL);

getch();

}

Your supposed to set-up the com port settings which is not shown here.  The ReadFile is not really used in this program but would allow you to read the data you just put in to confirm it.

Repairing the hand:

Repairs are almost completely done.  Everything is attached and most of the pairs are responding with good sensitivity. The only pair not working is the index finger.  For some reason the top was settled 100ohms higher then it was supposed to be.  Ground off this connection and glued a new strain gauge and terminal to it.