Of course after sending short program to set calc in Pause, I have to send "Enter" instructions to unfreeze calc with something like:
23 87 05 00 (where 05 means kEnter from http://merthsoft.com/linkguide/ti83+/keys.txt)
Edit:
Fixed it!

Old post:

I am attempting to receive a program from my calculator with an Arduino UNO. But there seems to be a problem, I tell the calculator that I can accept the program, but it is not responding with the VAR header.

Code:

Code:

#include <TIVar.h>
#include <CBL2.h>
#include <TICL.h>

#define LINE_RED    7
#define LINE_WHITE  6
#define DATA_MAX    255

#define null 0
#define NULL 0

TICL* ticl;

uint8_t recvHeader[4];
uint8_t recvData[DATA_MAX];

uint8_t sendHeader[4];
uint8_t sendData[DATA_MAX];

typedef struct{
  uint16_t   size;
  uint8_t    type;
  uint8_t    name[8];
  uint8_t    version;
  uint8_t    archived;
} variableHeader;

variableHeader *varHeader = (variableHeader*)recvData;
uint8_t varState = 0;

void setup() {
  Serial.begin(9600);
  ticl = new CBL2(LINE_RED, LINE_WHITE);
  ticl->resetLines();
  ticl->setVerbosity(true, &Serial);
}

void loop() {
  int ret;
 
  getData();
}

void getData(){
  int length = 0;
  int ret = 0;
 
  ret = ticl->get(recvHeader, recvData, &length, DATA_MAX);
  if(ret){
    return;
  }
 
  Serial.println("Handling packet");
 
  uint8_t machineId = recvHeader[0];
  uint8_t commandId = recvHeader[1];
 
  if(machineId != 0x83){
    return;
  }
 
  switch(commandId){
    // Variable header
    case VAR:
      varState = 1;
      sendACK();
      sendCTS();
      break;
    // Ready?
    case RDY:
      sendACK();
      sendCTS();
      break;
  }
}

/*
  uint16_t   size;
  uint8_t    type;
  uint8_t    name[8];
  uint8_t    version;
  uint8_t    archived;
*/

void handleProgram(){
  uint16_t programLength = recvData[13] + (recvData[14] << 8);
  Serial.println(programLength, HEX);
 
  for(int i = 0; i < programLength; i++){
    Serial.println(recvData[15 + i], HEX);
  }
}

void sendCommand(uint8_t command, uint8_t machine, uint16_t data){
  sendHeader[0] = machine;
  sendHeader[1] = command;
  sendHeader[2] = data & 0xFF;
  sendHeader[3] = data >> 8;
 
  ticl->send(sendHeader, null, 0, null);
}

void sendACK(){
  sendCommand(ACK, CALC83, 0);
}

void sendCTS(){
  sendCommand(CTS, CALC83, 0);
}


Serial output:
Quote:

Recv typ 0x68 from EP 0x83 len 11
Handling packet
snd type 0x56 as EP 0x83 len 0
snd type 0x9 as EP 0x83 len 0
First off, thanks for the awesome library Smile.

I'm using it to build a keyboard for my TI-89 Titanium. Here's a trimmed down version of the code I'm using:


Code:
#include "TICL.h"

TICL* ticl;
int lineRed = DEFAULT_TIP;
int lineWhite = DEFAULT_RING;

void setup() {
  pinMode(4, INPUT_PULLUP);
  Serial.begin(9600);
  ticl = new TICL(lineRed, lineWhite);
  ticl->resetLines();
  ticl->setVerbosity(true, &Serial);
 
  writeKey(90);    // Type 'Z'
}

void writeKey(int id)
{
  int rlen = 0;
  int rval = 0;
  uint8_t header[4] = {CALC89, KEY, id, id >> 8};
  rval = ticl->send(header, NULL, 0);              // Send KEY message
  rval = ticl->get(header, NULL, &rlen, 0);             // Get ACK
}


It works correctly, except for the fact that some of the keycodes don't match up with what TI says they should be ( Page 924 in the Ti-89 guide book).

To investigate, I wrote a quick program for my calculator and tried sending keycodes from my computer to see what they would be interpreted as:

Code:
xyz()
Prgm
   While true
      getKey()→k
      If k>0 Then
         Disp k
      EndIf
   EndWhile
EndPrgm


Some numbers went through just fine, like 90/Z, 275/F8, and 4109/Entry. However, others were interpreted differently. When I sent 8341/Symbol, the calculator reported 16533. In binary, it appears that one of the 0s never went through on the high byte. This always happens, even when using my friend's Ti-89 Titanium. Intrigued, I tried sending 16533 to the calculator. It reported that I had pressed 8341! So in this case, a binary 0 was added to the right side of the high byte.

So, I have a kludgy way of figuring out what each keycode should be and can make my program work. I'm just curious if I'm doing something wrong, if this is documented (or undocumented but de-facto) behaviour of the Ti-89, or if there's an issue with the library.
16533 is 0x4095, whereas 8341 is 0x2095. Some translation between bits 13 and 14 occurs in the linking code. Try using the other model type as first byte of the header ?

The values of KEY_SHIFT and KEY_DIAMOND on the 89/89T (small keyboard) and the 92+/V200 (large keyboard) are swapped, and for good measure, the direction keys' code values are rotated. See https://debrouxl.github.io/gcc4ti/kbd.html , especially the ngetchx() section, and https://debrouxl.github.io/gcc4ti/compat.html .
I must apologize that I didn't get around to answering your question sooner, Daniel. As you and Lionel both indicated, it looks like bits 13 and 14 are getting swapped, or that the high byte is getting shifted/rotated. Can you please try again with a value with more 1 bits in the high byte to see if the entire byte is being shifted or rotated?
*bump* Geekboy1011 put together a video demonstrating loading an ArTICL sketch onto your Arduino, connecting your Arduino and TI-84 Plus or TI-83 Plus, and testing out one of the example sketches includes with ArTICL.

I have a compiling problem:

Quote:
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows 7), Board: "Arduino Uno"
ControlLED.cpp.o: In function `onGetAsCBL2(unsigned char, Endpoint, int)':
E:\Programming\Arduino/ControlLED.ino:92: undefined reference to `TIVar::sizeWordToInt(unsigned char*)'
E:\Programming\Arduino/ControlLED.ino:95: undefined reference to `TIVar::realToFloat8x(unsigned char*, Endpoint)'
ControlLED.cpp.o: In function `loop':
E:\Programming\Arduino/ControlLED.ino:72: undefined reference to `CBL2::eventLoopTick(bool)'
ControlLED.cpp.o: In function `setup':
E:\Programming\Arduino/ControlLED.ino:56: undefined reference to `CBL2::CBL2(int, int)'
E:\Programming\Arduino/ControlLED.ino:57: undefined reference to `TICL::resetLines()'
E:\Programming\Arduino/ControlLED.ino:63: undefined reference to `CBL2::setupCallbacks(unsigned char*, unsigned char*, int, int (*)(unsigned char, Endpoint, int), int (*)(unsigned char, Endpoint, int*, int*, unsigned char (**)(int)))'


I included files into the project, but it doesn't compile, gives me these errors.
It looks like you're not including the TIVar, CBL2, and TICL header files. Can you show us your code?
KermMartian wrote:
It looks like you're not including the TIVar, CBL2, and TICL header files. Can you show us your code?


I'm just using the Controll LED example included in the ArTICL files.


Code:
#include "CBL2.h"
#include "TIVar.h"

CBL2* cbl;
const int lineRed = DEFAULT_TIP;
const int lineWhite = DEFAULT_RING;
...


I used the Sketch->Add files... to add the files in the project, could that be the problem? As far as I can tell, they have all been included correctly.
So I have figured out the problem. The Arduino software didn't add the library correctly, so even though the files were added in the project and included in the code, it did not work correctly.

I have had success compiling and sending code to my Arduino, but now I'm stuck with my calculators. The example programs all compile and send correctly, but they will not communicate with my calculators. Any tips on where I should begin debugging?
What kind of cable are you using? What pins are the wires in the cable connected to? How can you tell it's not working (for an easy start, try the TypeLetter example, since it requires you do nothing on the calculator)?
KermMartian wrote:
What kind of cable are you using? What pins are the wires in the cable connected to? How can you tell it's not working (for an easy start, try the TypeLetter example, since it requires you do nothing on the calculator)?


I am using the basic 2.5mm-2.5mm link cable, from my TI-84PSE and my TI-84CSE (not at the same time). The pins are connected through the shield to pins 6 and 7 on my Arduino, and I made sure to adjust the code as such. None of the demos will communicate with the calculator. The TypeLetter demo will not send the keypress to either calculator. I used LEDs on pins 6 and 7 to see if they were actually changing based on the code, and they are.
16aroth6 wrote:
KermMartian wrote:
What kind of cable are you using? What pins are the wires in the cable connected to? How can you tell it's not working (for an easy start, try the TypeLetter example, since it requires you do nothing on the calculator)?


I am using the basic 2.5mm-2.5mm link cable, from my TI-84PSE and my TI-84CSE (not at the same time). The pins are connected through the shield to pins 6 and 7 on my Arduino, and I made sure to adjust the code as such. None of the demos will communicate with the calculator. The TypeLetter demo will not send the keypress to either calculator. I used LEDs on pins 6 and 7 to see if they were actually changing based on the code, and they are.



Just for information. The default ring and tip of article are pins 2 and 3 not pins 6 and 7. Please double check you are using the correct pins. The pins are different with RFdave's shield. Which I believe I did happen to go over in the video above (~3:05 in the video)^^
geekboy1011 wrote:

Just for information. The default ring and tip of article are pins 2 and 3 not pins 6 and 7. Please double check you are using the correct pins. The pins are different with RFdave's shield. Which I believe I did happen to go over in the video above (~3:05 in the video)^^


I did watch the video, and I am using a shield. I meant to say that I adjusted the code so that the tip and ring lines were on the correct IO pins (6 and 7).
It's a silly question, but you also connected ground, right? And do you make absolutely sure you don't have tip and ring reversed?
KermMartian wrote:
It's a silly question, but you also connected ground, right? And do you make absolutely sure you don't have tip and ring reversed?

The ground pin is connected to every ground pin on the board through the shield. I have tried swapping tip and ring several times already with no success. I currently have it running with lineRed=6 and lineWhite=7.

Edit: finally got it to work... Several hours later
It took several tries before I figured out that Red needs to be 7 and White needs to be 6. I also dug some massive dust and dirt clods out of my IO ports... Anyways it finally works.
Haha, oh no, I should have thought of the possibility of cleaning out your I/O port. I was going to ask if your cable wasn't going all the way into the port, but I thought that was only possible if it was not one of TI's cables and therefore had a rubber part too large to fit in the calculators' link port case hole. So the problem was indeed swapping tip and ring between pins 7 and 6? Sad I'm sorry that it took so long to figure out. Can you think of a way that I could make that less confusing for other ArTICL users?
KermMartian wrote:
Haha, oh no, I should have thought of the possibility of cleaning out your I/O port. I was going to ask if your cable wasn't going all the way into the port, but I thought that was only possible if it was not one of TI's cables and therefore had a rubber part too large to fit in the calculators' link port case hole. So the problem was indeed swapping tip and ring between pins 7 and 6? Sad I'm sorry that it took so long to figure out. Can you think of a way that I could make that less confusing for other ArTICL users?


I think most of it is pretty straight forward, I would recommend adding instructions in the ArTICL setup to make sure that you Add the ArTICL library through the Arduino programming software... it took me a while to figure that one out also. The IO ports are my fault... I should have suspected that also. I knew they were a little dirty, but I didn't think there was as much dirt in them as there was. It totally made sense when I was cleaning it out.

I have several projects in mind, I messed around a bunch with it after I got it working last night. I will make a thread for my little projects I use it for.
Thanks for the suggestion, 16aroth6. I'll try to add more instructions about getting started with ArTICL to the readme, although I hope that most students and teachers will take a look at geekboy's excellent video. In other news, I added a new example sketch called SimpleIO to ArTICL, along with the TI-84 Plus C Silver Edition-side program that it interacts with. This demo is designed specifically for rfdave's new Arduino globalCALCnet Adapter 1.1 shield, uses F1-F3 to toggle the R/G/B LEDs on the shield, and also is designed to read a pushbutton and a slide switch and control the speed of a motor. I'll be expanding the SIMPLEIO.8xp program with more instructions and graphics when I have time (certainly before the end of February).
I started messing around with ArTICL again today, and ran into some errors. When I run the TypeLetter demo, nothing happens on the calc side, and the arduino keeps repeating

Code:

snd type 0x87 as EP 0x23 len 0
Sending byte 35
Sending byte 135
Sending byte 166
Sending byte 0
died waiting for bit 0
Get returned -6
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 3 of 5
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement