I wrote these a few months ago for my Arduino to TI-84+ linking project; I thought they might be useful to others. You basically call resetLines() at the beginning of the program, then par_put and par_get as necessary. Note that these of course use the TI-OS protocol, so you can use them for remote control, program injection, screenshot fetching, and all that fun stuff.
void resetLines() {
pinMode(TIring, INPUT); // set pin to input
digitalWrite(TIring, HIGH); // turn on pullup resistors
pinMode(TItip, INPUT); // set pin to input
digitalWrite(TItip, HIGH); // turn on pullup resistors
}
static int par_put(uint8_t *data, uint32_t len) {
int bit;
int i, j;
long previousMillis = 0;
uint8_t byte;
for(j=0;j<len;j++) {
byte = data[j];
for (bit = 0; bit < 8; bit++) {
previousMillis = 0;
while ((digitalRead(TIring)<<1 | digitalRead(TItip)) != 0x03) {
if (previousMillis++ > TIMEOUT)
return ERR_WRITE_TIMEOUT+j+100*bit;
};
if (byte & 1) {
pinMode(TIring,OUTPUT);
digitalWrite(TIring,LOW);
previousMillis = 0;
while (digitalRead(TItip) == HIGH) {
if (previousMillis++ > TIMEOUT)
return ERR_WRITE_TIMEOUT+10+j+100*bit;
};
resetLines();
previousMillis = 0;
while (digitalRead(TItip) == LOW) {
if (previousMillis++ > TIMEOUT)
return ERR_WRITE_TIMEOUT+20+j+100*bit;
};
} else {
pinMode(TItip,OUTPUT);
digitalWrite(TItip,LOW); //should already be set because of the pullup resistor register
previousMillis = 0;
while (digitalRead(TIring) == HIGH) {
if (previousMillis++ > TIMEOUT)
return ERR_WRITE_TIMEOUT+30+j+100*bit;
};
Would you be able to explain what the code calc-side should look like?
An excellent question. First of all, this can be used out-of-the-box for things like remote-controlling a calculator with injected keypresses, taking remote screenshots, and just about everything on this page from the File Format/Link Protocol Guide. Of course, if you're using it to chat with a user program, I like to recommend that you use CALCnet instead, but with the Rec1stByte and SendAByte bcalls, you can indeed interface with these routines. Both routines use the accumulator for the byte to send or receive and use the TI-OS error system if something goes wrong.
Ah, right. It's the whole silent linking thing, right? So you can just send it commands and the OS will handle things. Good to know about the Rec1stByte and SendAByte bcalls, though. Thanks!
Is there any difference between the TI-83 Linking protocol and TI-89t Linking protocol? I'm asking because I'd like to control a couple of servos using my calculator, which is the only I have in my possession.
Is there any difference between the TI-83 Linking protocol and TI-89t Linking protocol? I'm asking because I'd like to control a couple of servos using my calculator, which is the only I have in my possession.
The bottom two or three layers (if you subscribe to the OSI model) are the same: bytes and bits and the physical connection are the same, other than some voltage-leveling quirks.
Hi.
I'm not very good at electronics and stuff so...
How should I connect the calculator? I have some simple 2,5 mm to 3,5 mm audio cables (which are usable to connect two TI-83 calcs), but I don't have any official cables.
What wires do I have to connect to the Arduino?
Also, How can I send a command?
Hi.
I'm not very good at electronics and stuff so...
How should I connect the calculator? I have some simple 2,5 mm to 3,5 mm audio cables (which are usable to connect two TI-83 calcs), but I don't have any official cables.
What wires do I have to connect to the Arduino?
Also, How can I send a command?
Welcome to Cemetech! You should Introduce Yourself if you get a change. That code is exactly right, as long as you have resetLines() at the beginning of your program somewhere. Ground should go to ground, and the two signal lines should go to GPIO pins on the Arduino. You get to define that yourself:
Thank you SO much for finally releasing this code. So much more helpful this way. But I can't just use the Omnicalc linking commands... I'm reading your other links that your pointed out to see how my particular calc-side needs to be. Also, I'll need to add in some stuff that interprets the html for me, but this is going to help a lot!
I released this over a year and a half ago; look at the date on the first post. What are you talking about with HTML? Why not just use CALCnet and Gossamer?
So if i for example wanted to send the keypress "A" to my TI, would this work:
Code:
uint8_t A [4] = {0x23,0x15,0x41,0x00};
par_put(A, 4);
?
Welcome to Cemetech! A capital 'A' is 0x9A instead of 0x41 according to this list of keycodes, but other than that, yes. By the way, be sure to Introduce Yourself when you get a chance.
void loop(){
uint8_t A [4] = {0x23,0x15,0x41,0x00}; //packet for sending capital A
par_put(A, 4); //send the packet
delay(2000);
}
//TI LINK PROTOCOL CODE
void resetLines() {
pinMode(TIring, INPUT); // set pin to input
digitalWrite(TIring, HIGH); // turn on pullup resistors
pinMode(TItip, INPUT); // set pin to input
digitalWrite(TItip, HIGH); // turn on pullup resistors
}
static int par_put(uint8_t *data, uint32_t len) {
int bit;
int i, j;
long previousMillis = 0;
uint8_t byte;
for(j=0;j<len;j++) {
byte = data[j];
for (bit = 0; bit < 8; bit++) {
previousMillis = 0;
while ((digitalRead(TIring)<<1 | digitalRead(TItip)) != 0x03) {
if (previousMillis++ > TIMEOUT)
return ERR_WRITE_TIMEOUT+j+100*bit;
};
if (byte & 1) {
pinMode(TIring,OUTPUT);
digitalWrite(TIring,LOW);
previousMillis = 0;
while (digitalRead(TItip) == HIGH) {
if (previousMillis++ > TIMEOUT)
return ERR_WRITE_TIMEOUT+10+j+100*bit;
};
resetLines();
previousMillis = 0;
while (digitalRead(TItip) == LOW) {
if (previousMillis++ > TIMEOUT)
return ERR_WRITE_TIMEOUT+20+j+100*bit;
};
} else {
pinMode(TItip,OUTPUT);
digitalWrite(TItip,LOW); //should already be set because of the pullup resistor register
previousMillis = 0;
while (digitalRead(TIring) == HIGH) {
if (previousMillis++ > TIMEOUT)
return ERR_WRITE_TIMEOUT+30+j+100*bit;
};
How do you have the calculator's link port connected to the Arduino?
I purchased a 2.5mm jack and soldered some wires to the correct terminals.
And it's a stereo (3-conductor) jack? Are you sure you have the two signal pins on the right Arduino pins, and the ground to ground? Does the calculator's cursor change at all?
How do you have the calculator's link port connected to the Arduino?
I purchased a 2.5mm jack and soldered some wires to the correct terminals.
And it's a stereo (3-conductor) jack? Are you sure you have the two signal pins on the right Arduino pins, and the ground to ground? Does the calculator's cursor change at all?
I can try it later; I need to get my Arduino from my office. Make sure that the plug is flush into your calculator's port, by the way. Do you have a TI-83+/SE or a TI-84+/SE? If the latter, regular 2.5mm plugs sometimes have too wide of a flange (the metal disc below the plug) to fully mate into the socket.