1) Did you make sure that all of the wires are connected to the Arduino in the right place? I seem to recall that in the past, you changed the pin assignments.
2) Is the calculator at the homescreen?

Edit: And of course make sure you have pulled the latest commits.
KermMartian wrote:
1) Did you make sure that all of the wires are connected to the Arduino in the right place? I seem to recall that in the past, you changed the pin assignments.
2) Is the calculator at the homescreen?

Edit: And of course make sure you have pulled the latest commits.

1) Yes, the wires are connected correctly, I even tried switching them, but to no avail.
2) Yes, the calculator is on the homescreen

And yes, I do have the very latest version.
Hi


EDIT : I found a solution. See at the end of the post

This library is awesome but I have some troubles.
I modified the SimpleIO example to get the Altitude from a MPL3115A2 Adafruit sensor. I want to have the current Altitude and max altitude displayed on my TI-83 Plus. That is not a problem; I do it with this code in the onSendAsCBL2 function:


Code:
int rval;
 
voltage = baro.getAltitude();

if (voltage > voltageMax)
{
  voltageMax = voltage;
}

 Serial.println(voltage);
 Serial.println(voltageMax);
 rval = TIVar::longToReal8x(voltage, &data[offset], model);


 
  if (rval < 0) {
    return -1;
  }
  offset += rval;
 
  rval = TIVar::longToReal8x(voltageMax, &data[offset], model);
  if (rval < 0) {
    return -1;
  }
  offset += rval;

  return 0;
}

But what I want is to store the altitude in a variable and then send it to the TI-83 Plus when I plug it in. So I have to move the baro.getAltitude() in the void loop. But it doesn't work. When I do that, it doesn't send anything to the TI-83 Plus.

Do you have any idea ?

Sorry for my english, I'm french.

Eventually, I found a solution. The problem didn't come from your library but from the sensor's one. Instead of using the Adafruit library (where I bougth the sensor) I use the Sparkfun library. Now, it works really well !

Thank's for this awesome library !
You're welcome; I'm glad you were able to figure out what was wrong! I wonder what the Adafruit library was doing, though; perhaps it blocks in some way? I'd be curious to know if you figure it out. Also, I strongly encourage you to start a Your Projects topic about this project so we can see what you're creating.
I didn't figure out why it was doing that with the Adafruit library... I'm making a water rocket so I needed a cheap altimeter. So, I'm using an Arduino Nano and a MPL3115A2 Adafruit sensor. Then, I use the TI 83+ as a screen for my altimeter when my water rocket comes back. I hope the sensor will give quite precise altitude.
I'm looking forward to other projects with this library like a piano or a controller for an Arduino robot.

Is the logic level of the TI 5V? Doesn't it cause problems to directly wire it to the Arduino? Because I know Casio uses a 4.2V (or 4.1V) logic level, so you have to use a diode or something else to make the voltage go down to the right voltage.
You do indeed, but the z80 TI calculators use 5V (or at least 5V-safe) I/O (DBUS) ports, so there's no problem wiring it directly to the Arduino's pins. That water rocket sounds like fun; now that I know what the project is, I'm even more keen for you to post a Your Projects thread. Smile
Thanks for the information. Smile
I'll post a Your Projects thread after my first flight. Right now, I only made the electronic (not complicated, just wired the TI 83+ and the sensor to the Arduino) and the parachute. I also made the Arduino program and the TI program. I hope I can test it in real condition soon.
I was looking though this cool thread, and decided it to do it for myself. I know this is an old thread, but I have the exact same calculator used in the tutorial, but instead of using the 2.5mm connector from the calculator to the arudino, I soldered the 3 wire instead, and plugged them directly to the arduino. I have an arduino uno, and the problem is, is that my calculator freezes, and "TypeLetter" program does not work.
It's an old thread, but it's not a defunct thread. It sounds like you are grounding one or both of the data pins to ground; are you sure you have the correct wires going to the correct pins? And what 2.5mm plug are you using? Make sure that it's one that can go all the way into the calculator's 2.5mm socket.
KermMartian wrote:
It's an old thread, but it's not a defunct thread. It sounds like you are grounding one or both of the data pins to ground; are you sure you have the correct wires going to the correct pins? And what 2.5mm plug are you using? Make sure that it's one that can go all the way into the calculator's 2.5mm socket.


What I meant was that I didn't use the 2.5mm jack, I instead took apart the calculator and soldered 3 wires around the 2.5mm jack connector, where the 3 connections were. Thanks for the help, because you might be right. I might of accidentally had the solder connections touching ground.
Good luck figuring out if that's the case. If you don't connect the wires to anything, the calculator should function normally; if not, you might have bridged a connection. Make sure that your wires plugged into the Arduino are also going to the right pins, though, namely pins with the INPUT_PULLUP set. Otherwise, those connections will default to ground, producing the same effect.
Thanks for your help! Turns out I mistakenly thought some other connector was ground, which resulted as a bridged connection. BTW, while your program "TypeLetter" the calculator is supposed to freeze right? Because I don't know if its the arduino's fault because I plugged the ground connector to the different ground header on the arduino, and the calculator can function while the "TypeLetter" program is running. But the other ground header I plugged into resulted the calculator to be freezing, but still types the letter M.
No, the calculator shouldn't be frozen while the TypeLetter program is running. If it is, it means one of the connections isn't returning to floating +5V when communication isn't occuring.
Hello. I am new to programming Arduinos and would like to know how the following lines in "ControlLED.ino" and "SimpleIO" either send or get variables to or from the Ti Calulator

SimpleIO.ino

Code:

// Callback when the CBL2 class notices the attached calculator
// wants to start a Get() exchange. The CBL2 class needs to get
// any data to send before continuing the exchange.
int onSendAsCBL2(uint8_t type, enum Endpoint model, int* headerlen,
                 int* datalen, data_callback* data_callback)
{
  Serial.print("Got request for variable of type ");
  Serial.print(type);
  Serial.print(" from endpoint of type ");
  Serial.println((int)model);
 
  if (type != VarTypes82::VarRList)
    return -1;
 
  // Compose the VAR header
  *datalen = 2 + TIVar::sizeOfReal(model) * 2;
  TIVar::intToSizeWord(*datalen, &header[0]);  // Two bytes for the element count, ANALOG_PIN_COUNT Reals
                                                // This sets header[0] and header[1]
  header[2] = VarTypes85::VarRList;             // RealList (if you're a TI-85. Bleh.)
  header[3] = 0x01;                // Name length
  header[4] = 0x41;                // "A", as per "standard" See http://www.cemetech.net/forum/viewtopic.php?p=224739#224739
  header[5] = 0x00;                // Zero terminator (remainder of header is ignored)
  *headerlen = 11;
 
  // Compose the body of the variable
  data[0] = 2;   // Little-endian word for number of
  data[1] = 0;            // elements in this list
  int offset = 2;         // Offset past the count word

  // Convert the value, get the length of the inserted data or -1 for failure
  int rval;
  rval = TIVar::longToReal8x(digitalRead(BUTTON_PIN), &data[offset], model);
  if (rval < 0) {
    return -1;
  }
  offset += rval;
  rval = TIVar::longToReal8x(digitalRead(SWITCH_PIN), &data[offset], model);
  if (rval < 0) {
    return -1;
  }
  offset += rval;

  return 0;
}


ControlLed

Code:

// Callback when the CBL2 class notices the attached calculator
// wants to start a Get() exchange. The CBL2 class needs to get
// any data to send before continuing the exchange.
int onSendAsCBL2(uint8_t type, enum Endpoint model, int* headerlen,
                 int* datalen, data_callback* data_callback)
{
  Serial.print("Got request for variable of type ");
  Serial.print(type);
  Serial.print(" from endpoint of type ");
  Serial.println((int)model);
  return -1;      // -1 means we have no data to send.
}


and


Code:

// Callback when the CBL2 class has successfully received a variable
// from the attached calculator.
int onGetAsCBL2(uint8_t type, enum Endpoint model, int datalen) {
  Serial.print("Got variable of type ");
  Serial.print(type);
  Serial.print(" from endpoint of type ");
  Serial.println((int)model);
 
  // We only want to handle lists.
  if (type != VarTypes82::VarRList)
    return -1;

  // Turn the LEDs on or off
  uint16_t list_len = TIVar::sizeWordToInt(&(data[0]));      // Convert 2-byte size word to int
  if (list_len == 1) {
    // It is indeed a 1-element list
   int value = TIVar::realToLong8x(&data[2], model);   // First list element starts after 2-byte size word
    Serial.print("Received value ");
    Serial.println(value);
    for(int i = 0; i < LED_PIN_COUNT; i++) {
      digitalWrite(ledPins[i], (value >> i) & 0x01);
    }
  } else {
    Serial.println("Must send a 1-element list!");
  }
  return 0;
}


Which functions, commands, or lines of code in the above manipulate the variables (and how) that send(VARIABLE) or get(VARIABLE) in Ti-basic use?
The Get() and Send() commands on the calculator were originally used to interact with the CBL/CBR devices, so the programs that use onGetAsCBL2() and onSendAsCBL2() are meant to be used with Send() and Get(). As you can see from the comments in the code you pasted, onGetAsCBL2() is triggered when the attached calculator uses Send() to send a variable, and onSendasCBL2() is triggered when the attached calculator requests a variable with Get(). It's up to you to then parse the received variable, or set up the variable to be sent, as per the header and body format appropriate for that particular variable. I'd be happy to clarify further about that latter bit if you have more specific questions.
Thank you for your reply. Here are (hopefully) more specific questions:

- If I were to Get() a string from the calculator to the arduino, how would the header and body be formatted in the onSendAsCBL2() function?
- How would one parse strings sent from a calculator using Get()? Is "TIVar::sizeWordToInt" or the like used to parse variables? If so, what would it look like for parsing strings?


I will hopefully be sending strings to and from the a ti-84+ and an arduino with an esp8266 module attached to communicate with the Google Maps APIs to display directions and location via wifi -based geolocation for my project in CC20.

EDIT:
Thanks entirely to MateoConLechuga, the following code will parse strings:



Code that goes in the onSendAsCBL2() function:


Code:
// Compose the VAR header
  unsigned int string_len = strlen(string);
  unsigned int len = 2 + string_len;
  header[0] = (uint8_t)(len & 255);
  header[1] = (uint8_t)(len >> 8);
  header[2] = VarTypes85::VarString;
  header[3] = 0x01;
  header[4] = 0x00;  // Str1, numbers increment from 0-9
  header[5] = 0x00;
  *headerlen = 11;
  *datalen = len;
 
  // Compose the body of the variable
  data[0] = (uint8_t)(string_len & 255);
  data[1] = (uint8_t)(string_len >> 8);
  strcpy(&data[2], string);


where "string" is a string that will be sent to the calculator.



Code that goes in the onGetAsCBL2() function:


Code:
 // variable for holding received string
  char string[255];
 
  // We only want to handle strings
  if (type != VarTypes82::VarString)
    return -1;
 
  uint16_t string_len = ((data[0]) | (data[1] << 8));
  strncpy(string, &data[2], string_len);
Nice work to you (or mostly Mateo?)! I'd like to suggest a few small changes to make it a little bit more robust:

Code that goes in the onSendAsCBL2() function:

Code:
// Compose the VAR header
  unsigned int string_len = strlen(string);
  unsigned int body_len = 2 + string_len;
  TIVar::intToSizeWord(body_len, &header[0]);  // Two bytes for the number of bytes in the string
  header[2] = VarTypes85::VarString;
  header[3] = 0x01;
  header[4] = 0x00;  // Str1, numbers increment from 0-9
  header[5] = 0x00;
  *headerlen = 11;
  *datalen = len;
 
  // Compose the body of the variable
  TIVar::intToSizeWord(len, &data[0]);  // Two bytes for the number of bytes in the string
  strcpy(&data[2], string);


where "string" is a string that will be sent to the calculator.

Code that goes in the onGetAsCBL2() function:

Code:
 // variable for holding received string
  char string[255];
 
  // We only want to handle strings
  if (type != VarTypes82::VarString)
    return -1;
 
  uint16_t string_len = TIVar::sizeWordToInt(&(data[0]));
  strncpy(string, &data[2], string_len);
The reason why I prefer not to use those routines in practice; or even in example code is because they are not portable; and it requires knowledge of how they work too rather than just the format.

How come there isn't a function which takes all of this in one go? It never really made sense to me why the size bytes have special case handling by functions that should really be inline macros.


Code:
TIVar::intToSizeWord(body_len, &header[0])


This is where I spent the longest time myself confused, and had to look at the actual source for the functions. How many bytes are modified in 'header'? Who knows? Does it vary from calc to calc? What is the next index I use?

My recomendation would just be simple macros that can extract the high and low bytes:


Code:
header[0] = low8(size);
header[1] = high8(size);


And the same for the simple | function as well. I guess the main thing I was going for is that readability wise, those functions are difficult to decipher. sizeWordToInt returns an unsigned 16 bit basically, but classifies it as an Int? Anywho. Rant over. Sorry about that Razz
My initial motivations for why I thought they were a good idea were roughly:
  1. Future-proofing for any file formats that require <>2 bytes for a size word
  2. Removing the need to understand (or boggle at) otherwise confusing bitshifting and bit math from the burden of a beginner programmer
  3. Relying on a decent compiler to make sure that there's no size or speed cost from these "function" calls.
Would you still prefer the individual functions/macros you suggested as-is for that, or just a cleaner interface to something closer to my functions?
So just to make sure. Does this work with an arduino nano and a Ti-84 plus ce calculator? If not, then is there anyway to connect an arduino nano and ti-84 plus ce calculator??
  
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 4 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