I recently bought a Arduino and Ethernet shield. In just a few minutes, it is possible to get a program running that returns search queries from google. From there, it was only a matter of minutes to set up a basic program that returns other websites. I am wanting to integrate this discovery with GCN to cut out the computer from the current equation. However, I cannot figure out how to inteface with the calc's serial protocol. I have tried sending bytes then strobing the clock pin, i have tried alternating back and forth between data and clock, but all of these return a -1 on omnicalc. That's it until i get some more data though Smile.
You don't want to integrate with gCn, you want to interface with CALCnet. CALCnet is the protocol that lets calculators (and other devices) network locally, while gCn is the set of Arduino software that bridges CALCnet to serial/internet and connects multiple gCn bridges together. I can give you Arduino code that speaks CALCnet, but I don't know if that's exactly what would be most helpful. I strongly suggest you first read the CALCnet whitepaper and try to understand how it works as far as toggling the link lines. I should also mention that I have a working set of routines for sending and receiving TI link protocol bytes over the link port from an Arduino.
Could you get me the uncompiled source? The hex is utterly useless in understanding anything! Razz And I've read the whitepaper several times on GCN but am unaware about the Calcnet paper. Could you also link me to the site? Thanks BTW Kerm, I see people have been pestering you about this around the forum! Very Happy
First Google result for CALCnet Whitepaper (Razz):
http://www.ticalc.org/archives/files/fileinfo/433/43304.html

Yes, I intentionally didn't release the source, because I don't want my code reused without my permission, which is a problem that I've dealt with frequently. Perhaps you'd be best served trying to read either the whitepaper above or the File/Format Guide I'm linking to below and re-implementing CALCnet or the TI link protocol yourself?

http://myserverathome.com/linkguide/hardware.html
I am having trouble getting any data sent or recieved. I tested voltages with a multimeter and was getting around 3 volts. The picture did help me understand the passage of data over time! But now the issue is that even when I try to duplicate the picture in software, i still am struggling to send even one byte over the link port. Kerm explained this as PWM, but there is no (as in REALLY tiny) capacitance on the output, so the signal change should be nearly instant. My meter should still read 5 volts but it isn't. That's about it for the moment.
You're pulsing the link port. If it spends 50% of its time high, and 50% low, then you'll see roughly V/2 averaged over time. You must be spending about 60% of the time high and 40% low.
Okay Kerm, there probably is some sort of tiny capacitance somewhere. The impedence of my meter isn't putting enough load onto that capacitance to make the effect I'm thinking of significant. Could you give me some pseudo code to build off of? Not source per se, but a sort of order of reading and writing from the calculators ports that creates a successful send? The graph of the order helps a lot, but I don't know how to create the necessary checks and acknowledgements between the Arduino and calc or how to pass a successful packet of data when the length of the packet varies so much.
I think you might have ignored what I said. If you hold the data line high, or low, it will be 5v or 0v. If it's pulsating very fast between the two, the voltage you'll see is more or less a time-weighted average as taken by the multimeter, indicating the average duty cycle of the signal scaled to the +V voltage.

The two pages that I linked to completely explain the CALCnet and TI protocols respectively; I used the TI page and that alone to write my own implementation, so I know it's enough information. The CALCnet documentation was written after I had drafted the design and coded it for z80, and it allowed me to write a sane Arduino version.
I am trying very hard to get a byte sent, and the most recent result is that the calc pushes the alpha key and then the X button and does nothing else. It only does this when the Arduino runs the code. I'm getting nervous about bricking my calc, but it's never bricked, even with pins shorted out. So, I'd like to see if anyone can explain this occurance. This is the code in the Arduino I wrote out:


Code:

void setup() {
  pinMode(6, OUTPUT); //DATA or RED
  pinMode(7, OUTPUT); //CLOCK or WHITE

 
void loop() {
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(7, LOW);
  digitalWrite(6, LOW);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, LOW);
  digitalWrite(6, LOW);
  digitalWrite(7, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, LOW);
  digitalWrite(6, LOW);
}


Followup Questions:
The above code isn't working for me. I think it is because the ports are set only in one direction. But the schematic in the GCN whitepaper shows a direct connect to the Arduino pins. Should I make a bidirectional data bus, or can I do that in software? If the arduino can do it in software, how to I configure that in the setup subroutine?
The diagram you linked me to, Kerm, helps me understand that the calculators will adjust to whichever one is xmitting, but it doesn't let me know what the ORDER in my code must be (Its the server at home page, not the white paper I'm thinking of...) Like, for example I want to send a byte. What I did above was pull the Data pin high then strobe the CLK pin. Is that how it works? Or should i xmit a whole byte THEN strobe the CLK pin? Is the CLK pin even doing something remotely like what I'm attempting, or am I going to brick my calc trying to find out?
You're just writing with absolutely no sense of timing whatsoever. Do you realize that all of that is completing in the very small microsecond time frame, verging on nanoseconds, and that the calculator is expecting things to happen muuuuch slower than that? Did you see in the protocol that it requires both reading and writing? Do you understand that there's no such thing as setting an Arduino pin as bidirectional, that you have to alternate between setting it as input and reading it and then setting it as output when you need to write to it?

Edit: For delay, you have three options:
:: http://arduino.cc/en/Reference/DelayMicroseconds
:: http://arduino.cc/en/Reference/DelayMilliseconds
:: Actively read in a loop until the event that you need to happen happens
I've been screwing around with timing, and now my calc is returning 255 from Omnicalc recieve when I use this code:

Code:

void setup() {
  pinMode(6, OUTPUT); //Data or RED
  pinMode(7, OUTPUT); //CLOCK or WHITE
}

void loop() {
  int x = 10000;
  digitalWrite(6, HIGH);
  delayMicroseconds(x);
  digitalWrite(7, HIGH);
  delayMicroseconds(x);
  digitalWrite(7, LOW);
  delayMicroseconds(x);
  digitalWrite(6, LOW);
  delayMicroseconds(x);
  digitalWrite(6, HIGH);
  delayMicroseconds(x);
  digitalWrite(7, HIGH);
  delayMicroseconds(x);
  digitalWrite(6, HIGH);
  delayMicroseconds(x);
  digitalWrite(7, LOW);
  delayMicroseconds(x);
  digitalWrite(6, LOW);
  delayMicroseconds(x);
  digitalWrite(7, HIGH);
  delayMicroseconds(x);
  digitalWrite(6, HIGH);
  delayMicroseconds(x);
  digitalWrite(7, LOW);
  delayMicroseconds(x);
  digitalWrite(6, LOW);
  delayMicroseconds(x);
}


It seems with a delay of 10,000 us, the calc can recieve SOMETHING, but it isn't what I'm trying to send... So, my question now is how to send data that is going to be USEFUL. I can make variables, but I don't know how to make them 2 state being high or low or how to break up hex into pieces to send via this method in software. That is the next step, to take a hex bit and send it over the communication I have, and the next step after that is to make it bidirectional.

edit:
nvrmnd about the data type, i found out it is boolean data type and it's declared with just "boolean variablename = HIGH" or LOW if u want.

dbl nvrmnd because I found how to change data types using a loop with bit read increment and so forth. I'll edit again when I have the program running and working and continue with more questions as need be.

This is the new code, but it is returning nothing...

Code:

void setup() {
  pinMode(6, OUTPUT); //Data or RED
  pinMode(7, OUTPUT); //CLOCK or WHITE
}

void loop() {
  int x = 10000;
  byte Hex = 255;
  int Position = 0;
  for (Position<=7; Position++;){
  boolean Data = bitRead(Hex, Position);
  digitalWrite(6, Data);
  delayMicroseconds(10000);
  digitalWrite(7, HIGH);
  delayMicroseconds(10000);
  digitalWrite(7, LOW);
  delayMicroseconds(10000);
  }
}


I really excited about there being control structure and variables now though! Yippee! Very Happy
Update on my Progress:

I have been reading Kerm's papers and doing LOTS of experimentation, but I am still having trouble with getting any data transfer. This is the code I am using:


Code:
#include <SPI.h>

int Data = 7; //Data or TIP or RED
int Clock = 6; //Clock or RING or WHITE
byte DRead = 0;

void setup()
{
  Serial.begin(9600);
  delay(1000);
  Serial.println("Awesome Sauce! :)");
}

void loop()
{
  sendByte(1, 1, 1, 0, 0, 1, 1, 1);
}

int sendByte(boolean Bit0, boolean Bit1, boolean Bit2, boolean Bit3, boolean Bit4, boolean Bit5, boolean Bit6, boolean Bit7)
{
  //initialize the contact with the mothership

  pinMode(Data, OUTPUT);
  pinMode(Clock, OUTPUT);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(1000);
  digitalWrite(Clock, LOW);
  delayMicroseconds(9000);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(52);
  delayMicroseconds(110);
  digitalWrite(Data, LOW);
  digitalWrite(Clock, LOW);
  delayMicroseconds(52);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(42);

  //send data now
  int increment;
  for(increment<10; increment++;)
  {
  digitalWrite(Data, Bit0);
  delayMicroseconds(17);
  digitalWrite(Clock, LOW);
  delayMicroseconds(35);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(52);

  digitalWrite(Data, Bit1);
  delayMicroseconds(17);
  digitalWrite(Clock, LOW);
  delayMicroseconds(35);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(52);
 
  digitalWrite(Data, Bit2);
  delayMicroseconds(17);
  digitalWrite(Clock, LOW);
  delayMicroseconds(35);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(52);

  digitalWrite(Data, Bit3);
  delayMicroseconds(17);
  digitalWrite(Clock, LOW);
  delayMicroseconds(35);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(52);

  digitalWrite(Data, Bit4);
  delayMicroseconds(17);
  digitalWrite(Clock, LOW);
  delayMicroseconds(35);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(52);

  digitalWrite(Data, Bit5);
  delayMicroseconds(17);
  digitalWrite(Clock, LOW);
  delayMicroseconds(35);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(52);

  digitalWrite(Data, Bit6);
  delayMicroseconds(17);
  digitalWrite(Clock, LOW);
  delayMicroseconds(35);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(52);
 
  digitalWrite(Data, Bit7);
  delayMicroseconds(17);
  digitalWrite(Clock, LOW);
  delayMicroseconds(35);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(52); 
  }
}

int recieveByte(void)
{
  //initialize contact with the daughtership
 
  pinMode(Data, INPUT);
  pinMode(Clock, INPUT);
  DRead = digitalRead(Data);
  return DRead;
}


The code basically repeatedly sends the data stored in the 8 boolean "BitX" bits to the calculator. i used the timings described in the Calcnet 2.2 protocol paper. However, nothing is sending still. Any advice guys? I have connections with the internet, but still no connect with the calcs. Sad
It looks like you are getting the timings down now (though I haven't checked your code against the white paper), but I see that you're not sending any calculator id's (not even the broadcast id) nor the payload length. The CALCnet receiving code won't see any valid data without those pieces of data.

However, are you sure you're prepared to write something like this? I suggest you learn bitwise operations; they're very useful with bit-banging. You should also get an oscilloscope to see what's happening at the signal level.

Also, don't get discouraged if it takes you a long time to get this working. I have years of experience writing stuff like this and it still takes me many hours of failure before I'm successful. I'm sure Kerm would tell you the same thing.
I'm not necessarily trying to use Calcnet. To test it out, I've been using the Omnicalc linksend() command to do everything. It's not the same protocol. But I was hoping everything was the same between them, although I know this probably is not the case. And I know something (as in not a lot, but I'm familiar with) about bitwise operations, just look at my CPU project. I just haven't taken the time to get the protocol down well enough to write a loop that takes my byte and processes it in terms of bits though. I need more knowledge about how to actually send something before I can make a for(bitPosition<=7; bitPosition ++Wink kind of loop. It adds another level of complication for me. Smile

Nevermind. I went ahead and made the new program with the Bit operators. Still doesn't work though. Sad

Code:
#include <SPI.h>

int Data = 6; //Data or TIP or RED
int Clock = 7; //Clock or RING or WHITE
byte DRead = 0;
byte DataByte = 0;

void setup()
{
  Serial.begin(9600);
  delay(1000);
  Serial.println("Awesome Sauce! :)");
}

void loop()
{
  sendByte(255);
}

int sendByte(byte DataByte)
{
  //initialize the contact with the mothership

  pinMode(Data, OUTPUT);
  pinMode(Clock, OUTPUT);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(1000);
  digitalWrite(Clock, LOW);
  delayMicroseconds(9000);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(52);
  delayMicroseconds(110);
  digitalWrite(Data, LOW);
  digitalWrite(Clock, LOW);
  delayMicroseconds(52);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(42);

  //send data now
  int BitIncrement;
  for(BitIncrement<=7; BitIncrement++;)
  {
  int SendBit;
  bitRead(DataByte, BitIncrement);
  digitalWrite(Data, SendBit);
  delayMicroseconds(17);
  digitalWrite(Clock, LOW);
  delayMicroseconds(35);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(52); 
  }
}

int recieveByte(void)
{
  //initialize contact with the daughtership
 
  pinMode(Data, INPUT);
  pinMode(Clock, INPUT);
  DRead = digitalRead(Data);
  return DRead;
}
I use this AXE code:
:.COMPROT
:Lbl SEND
:For(r3,0,7
:0→r4
:r1^2→{r3+L1}
:r1/2→r1
:If {r3+L1}
:1→port
:Else
:2→port
:End
:Repeat port=0 or (r2*10=r4)
:r4+1→r4
:End
:If r2*10=r4
:Goto F
:End
:0→r4→port
:Repeat port=3 or (r2=r4)
:r4+1→r4
:End
:If r2=r4
:Goto F
:End
:End
:1→r1:0→port
:Return
:Lbl F
:0→r1→port:‾1→r2
:Return
:Lbl GET
:For(r3,0,7
:0→r4
:Repeat port=1 or (port=2) or (r1*10=r4)
:r4+1→r4
:End
:If r1*10=r4
:Goto F
:End
:If port=2
:2→port
:0→r4
:Repeat port=1 or (r1=r4)
:r4+1→r4
:End
:If r1=r4
:Goto F
:End
:0→port
:1→{r3+L1}
:Else
:1→port
:Repeat port=2 or (r1=r4)
:r4+1→r4
:End
:If r1=r4
:Goto F
:End
:0→{r3+L1}→port
:End
:End
:1→r1
:For(r3,0,6
:r2+{A-r3-1+L1}*2→r2
:End
:r2+{L1}→r2

I'm not sure if it works. I made it a long time ago
Dang it. I can't compile that and try because I'm on my Linux system and don't have a link program or a link cable near Sad. But I'm pretty sure it isn't what I need for my Arduino program, though this protocol might actually be easier to interface with. If I remember to try it out, I'll definately give it a shot, but right now, I can't compile. Sad
  
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 1 of 1
» 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