Shop OBEX P1 Docs P2 Docs Learn Events
Need a little bit of help interfacing through SX/B to MAX3100 — Parallax Forums

Need a little bit of help interfacing through SX/B to MAX3100

MRLMRL Posts: 13
edited 2007-07-02 02:27 in General Discussion
I am very new to SX chips and SX/B.· I am trying to interface to a MAX3100 UART·chip and I am having some difficulties.

I found some BS2 code to do this in the BS2 forum, and I am trying to adapt this program to SX/B.· I am attaching both programs (the older BS2 that someone else wrote and the new SX/B that I have attempted to write).· After I get past this challenge, I want to use the MAX3100 for a IRDA interface to an old Palm keyboard that I have, but first I need to be able to communicate between the SX and the MAX3100.

So far the code I created only tries to send the MAX3100 a configuration command and then immediately read back the MAX3100 configuration registers.· From what the BS2 code says, I should be getting back the exact same bit settings, but I am not even close.

I am sending "command1" and "command2" to the MAX3100 and I am reading out "commandIn1" and "commandIn2":

I will attach the two programs on this posting.· Anything anyone can do to help me get past this challenge would be great.

Thanks a lot in advance.

Mike
Saratoga Springs, NY

Comments

  • JonnyMacJonnyMac Posts: 9,215
    edited 2007-04-29 22:14
    Question: Is there a reason you want to use an external UART? With the SX, you have the horsepower to add "virtual peripheral" UARTs and other features. The program attached is from my May 2007 Nuts & Volts column that does serial-driven servo control. This code does a one-byte buffer but if you need more you can; in the Completed Projects forum there's a MIDI project I did some time back (also in SX/B and for Nuts & Volts) that implements an 8-byte receive buffer.

    If you do want to go the MAX3100 direction there's an extra step with SX/B's SHIFTIN and SHIFTOUT instructions: You need to manually set the clock line to the "off" state before the call as these instructions simply toggle that line. If the code worked with the BS2sx then use something like LOW Clock before those calls to set the clock line as the BS2sx does.
  • MRLMRL Posts: 13
    edited 2007-04-30 00:05
    Jon,
    Thanks for the tip on forcing the clock line low before I call the SHIFTIN and SHIFTOUT commands.· I have done this in my code, and unfortunately, I am getting the same response.· (I will attach an updated program to this reply)

    I think I need to use the MAX3100 because I want to interface to an old PALM IRDA keyboard.· I could not find any code examples or mention of creating a virtual peripheral that would recreate the basic IRDA interface.· I am not trying to recreate the whole IRDA protocol, just get it to read simple keystrokes from the Palm keyboard.· The MAX3100 has an IRDA mode that is supposed to be able to recreat the proper pulse timing and inverse bit interpretation to make reading IRDA easier.

    If you (or anyone else) has a better idea how to accomplish this I am ready to change directions!

    Any way, thanks again for your help, but I am still stuck with my original problem.

    Mike
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2007-04-30 00:13
    Hi Mike,

    I used the MAX3100 with the Stamp specifically for IRDA and have an article about it posted here:
    www.emesys.com/BS2IrDA.htm#Stamp
    That might give you further pointers.

    Hey Jon, I didn't realize that you had a new avatar! The article in N&V is a really nice piece of work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • MRLMRL Posts: 13
    edited 2007-04-30 00:47
    Tracy,

    Thanks for your response.

    Yes, I also found your post/program and tried to duplicate what you did with the BS2 on the SX.· Unfortunately, I was unsuccessful.· I think it is probably due to my inexperience with SX/B.

    I will keep plugging at it, but so far I am stumped.

    Mike
  • Mike GannMike Gann Posts: 2
    edited 2007-05-02 15:35
    HI Mike -

    I see a couple of problems with your code. First is your shiftout commands you are using to configure the device:

    ' send the configuration bytes to the UART to set up for receiving MIDI input
    ·· SHIFTOUT···· UartOutputPin, UartClockPin, MSBFIRST, command1\8
    ·· SHIFTOUT···· UartOutputPin, UartClockPin, MSBFIRST, command2\8

    You specify MSBFIRST, which is correct for the MAX3100. However you include the count parameter (\8) which forces the shiftout command to ignore the MSBFIRST and shift out the rightmost eight bits which· effectively turns your shiftout comands to:
    SHIFTOUT···· UartOutputPin, UartClockPin, LSBFIRST, command1
    SHIFTOUT···· UartOutputPin, UartClockPin, LSBFIRST, command2

    Just remove the count parameter, it is not needed in your case.

    The second problem is the way you are trying to read back the configuration. To write data to be transmitted or to read data which has been received you can use the shiftout / shiftin commands. To read the configuration of the MAX3100 you have to both write the command and read the data at the same time. To do this you can'y use the shiftin / shiftout commands.

    I have attached a program that writes the configuration, then reads it back. Run it·in debug and check the results.

    The code loop used to simultaneously read and write the SPI data was found on this forum but I do not remember who wrote it to give proper credit.

    I hope this helps.

    Mike
  • MRLMRL Posts: 13
    edited 2007-05-08 18:52
    Mike Gann,

    Thank you so much for your help - with your input and code example I was able to get my program to properly configure the MAX3100 and read back the configuration register.· I will post my updated program on this entry.

    I am now working through the last bit of the requirement for this program which is to capture the keystrokes coming from my Palm Wireless Keyboard through an IRdA ouput.· This part does not yet work, but I am MUCH farther along with this endeavor based on your inputs.

    I am trying to watch the IRQ pin of the MAX3100 and when it goes low read the incoming characters from the IRdA keyboard, but so far this segment of the code does not work (it just drops right through this section of the code and fails to read any value other than binary zero from the MAX3100).

    It will keep working on this segment, but I am much farther along based on your help - thanks again !

    Mike

    Saratoga Springs, NY
  • Mike GannMike Gann Posts: 2
    edited 2007-05-09 15:45
    Hi Mike -

    I haven't looked at your updated code but......

    Did you notice·the irq pin of the MAX3100 is an open-drain output and needs a pull up resistor?
    I overlooked that detail at first and it took me awhile to figure out why my code which looked right wasn't worklng.

    Best regards,

    Mike
  • MRLMRL Posts: 13
    edited 2007-05-20 14:56
    OK, I am really sumped !

    I have gotten pretty far along with my attempt to interface a MAX3100 to an SX28 chip using SX/B, but after much trial and error work I am stuck.

    I will enclose my latest program.

    This version is able to communicate properly with the MAX3100 and set up the contiguration registars.

    Here is my debug window after I send the command to the MAX3100: SEE ATTACHMENT Debug_Values_1.bmp

    And here is my debug window after I read back the configuration registers of the MAX3100: SEE ATTACHMENT Debug_Values_2.bmp

    I think everything is OK up to this point.· Now the trouble begins...· I can't seem to get a valid character read back from the MAX3100.· Just to review, I am attempting to use an old PALM portable keyboard and capture the IRDA from that device into my SX chip.· My next step will be to interface this SX chip back to another device, using the PALM keyboard for wireless character input.

    You will be able to see from my code that I have tried 2 different methods to detect a full byte being available from the MAX3100 (trying to use the IRQ pin and trying to interrogate the "R bit") and neither of these methods works.· I also attached a 330 ohm·pull-up resistor to the IRQ pin because it is an open drain type.· When running in the debugger with either of these methods uncommented and compiled in the code the code never gets a valid hit, so it never moves to grab the character.

    As the code is now, with both of these methods commented out, I can run the debugger in the "Poll" mode and get the watch variables to react, but I am only getting a hex 22 value no matter what key I press.· I have tried various combinations of 7 or 8 bit byte and stop bit combinations with the MAX3100 configuration, but this does not seem to matter.· I have also tried various settings on the baud bits, but again, I get the same hex 22 input.

    Can anyone help me on this - it has me baffled?

    Thanks in advance.

    Mike from Saratoga
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-05-21 19:34
    Mike,

    If the MAX3100 is supposed to signal the arrival of valid data via the state change of one of its pins and this is not occurring, I suggest you forego trying to read the data and investigate why this does not occur. Maybe it is not configured properly or maybe it is not receiving the data. My recommendation is to focus on getting the MAX3100 to recognize the data first then focus on reading it once you are certain it is in the chip.

    - Sparks
  • MRLMRL Posts: 13
    edited 2007-05-23 09:10
    Sparks,

    Thanks for this advice. I like your suggested approach. I will try to figure out why MAX3100 isn't detecting and reporting back that it has received data.

    Best regards,

    Mike
  • MRLMRL Posts: 13
    edited 2007-05-24 01:53
    I made some excellent progress on this journey today!

    I contacted the Maxim IC support line and an excellent Applications Engineer named Steve helped me a lot.

    Based on his inputs, here are the changes I made:

    1) Swapped out the 330 ohm pull-up resistor on the IRQ_not pin with a 2K ohm resistor (it is an open drain pin)
    2) Put a "1" in the RM bit of the configuration input to the MAX3100 to ensure that the IRQ_not pin would work properly
    3) Tied the SHND_not pin to Vcc to make sure the MAX3100 didn't go into some shutdown mode

    I now have success in getting the IRQ_not pin to react to the keyboard and that means that the SX/B program can reliably wait for a full 8 bit input from the MAX3100.

    At this point my last step is to mess with 4 final variables to get a good decode from the Palm IRDA keyboard:
    1) Parity on/off
    2) Word length - I think this has got to be 8 bits?
    3) Stop Bit (one or two)
    4) Baud

    I have the manual for my Palm keyboard but there is no mention on the communications settings.

    I guess if I had an O-scope I could just measure the inputs from the keyboard and determine all of this, but I don't have that equipment. Steve from Maxim IC had another idea to measure the Rx pin to try to get the timing between bits and use that to determine the baud. I will probably try that next.

    Thanks again to everyone for your help - I made some great progress today based on your inputs. Now if I can only discover the rest of the details of the Palm Keyboard output I will be all set...

    Best regards,

    Mike
  • Mike GreenMike Green Posts: 23,101
    edited 2007-05-24 04:53
    Most stuff doesn't use parity these days. Use Parity Off

    Without parity, you need 8 data bits for a word length

    You could use either one or two stop bits. I'd use one unless you need the extra time.
    This usually applies to transmit only. Most serial receivers are designed for one stop bit and will ignore more.

    Can't help you much on the Baud. Try 115K. It's easy enough to try several different Bauds.
  • MRLMRL Posts: 13
    edited 2007-06-09 19:10
    OK, I am determined to get this to work !

    I purchased the Parallax USB Oscilloscope and have taken some measurements that I need help intrepreting.

    I am enclosing a bitmap of the screen capture from the O-scope software.

    I am pretty sure the Palm Keyboard that I am trying to decode from sends multiple characters for one key press.· As such, I can't really figure out where the boundaries of the unique byte sets start and finish.

    I used the horizontal and vertical cursors of the O-scope software and I think I have determined that the baud rate is about 10K, but if somenone can confirm that for me please do so.· Also, the individual bits are negative rather than positive.· Am I looking at this correctly?· Should the MAX3100 chip be able to understand this?

    Finally, how can I determine where the start bit is within this stream?· What I ultimately need is the specifications to send to the MAX3100 chip so that it can properly decode the incoming IRDA from the Palm keyboard.

    I was thinking that the MAX3100 chip should take care of this, but it is not handling it at this time.

    So, if anyone can take a look at this picture and help me intrepret the data, that would be much appreciated.

    Best regards,

    Mike
    Saratoga Springs, NY
  • MRLMRL Posts: 13
    edited 2007-06-11 02:58
    OK, I think I am getting closer.· I have reworked the IrDA receive circuit and now have the bit stream being represented as positive pulses.

    I will enclose the bitmap from the Parallax O-scope.

    Unfortunately, I am still getting bad decodes (I will also enclose the program).

    If anyone can help it would be GREATLY appreciated.

    Best regards,

    Mike
    Saratoga Springs, NY
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2007-06-11 04:54
    Mike,

    The rx input on the MAX3100 expects pulses of the first form, like the first picture you posted, normally high (+5 volts) with pulses going to ground (0 volts). However, the signal in that picture is too weak. It only drops from 5 down to 3 and shows a long decay time constant. Try bringing the keyboard closer to the receiver, or use a more sensitive receive circuit. Is that in fact the signal presented to the rx input?

    I think you are reading the bit time correctly. At ~100 microseconds per bit, it is probably 9600 baud. That is the nearest standard baud rate.

    It does seem strange that there is so much action when you press just one key. Maybe it sends several bytes per key. Can you set the 'scope to capture just the action that follows a single key press, for example, one tap on the letter "A"?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • MRLMRL Posts: 13
    edited 2007-06-13 02:19
    Tracy,

    I have reverted back to the earlier IrDA receive circuit.· Here is a capture of the bit stream from pressing an "a" key.

    I do believe the keyboard sends more than one character string per key press.

    The signal is not totally clean and it does not go to zero, but rather bottoms out at about 1.08 volts.

    In your opinion, should this be sufficient for the MAX3100 to reliably decode the bits or do I need to rework the receive circuit to really get the pulses down to zero volts?

    Thanks so much for your help.

    Best regards,

    Mike
  • Tracy AllenTracy Allen Posts: 6,666
    edited 2007-06-13 16:49
    The input will need to be pretty clean. I'd suggest you add another comparator or schmitt trigger before the MAX3100 input, in order to square up the signal and to be sure the pulses are sufficient height and also width.

    Another thing about the MAX3100 IRDA is that it requires the input pulses to be at least 3/16 of the bit duration. So at 9600 baud, each pulse should be at least 20 microseconds long, or it will not register. The relaxed version of the IRDA standard allows pulses as short as 1.6 microseconds at any baud rate, for power conservation. The Palm in general accepts the shorter pulses, and the keyboard might send shorter pulses.

    Your receive circuit evidently is doing some RC pulse stretching, which may be a good thing. You just need a comparator to make the pulses long enough and solidly down to 0 volts.

    I don't know what to think about the protocol. Have you dug into Google to find info about it? I have Palm developer docs, but they doesn't seem to "touch" on the keyboard.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • MRLMRL Posts: 13
    edited 2007-07-02 02:27
    I have been doing some data analysis and I am enclosing the pictures.

    The bottom line is that I have the program set up for 9600 baud, IRDA, no parity, one stop bit and that seems to be able to understand the pulses coming from the Palm Keyboard.

    I had to add a 555 timer ic to the IRDA receive circuit to elongate the pulses and to ensure the complete swing of each pulse from around 4.5 volts to around 0 volts. This is shown in my pictures - the blue signal is coming directly off the photo transistor - the red signal is coming off the 555 circuit with the wider pulse and full voltage swing.

    My last problem is that I am not getting any pulse train decoded that matches a standard ASCII code. I thought that was what I was working towards?

    Also, even with the MAX3100 set with the configuration I mentioned above, the chip seems to be "skipping" 3 bits after each 8 bit string???? I could understand skipping one bit as a stop bit, but I don't understand the 2nd and 3rd bit skip? Are there two start bits?

    Any way, I feel like I am getting very close to a solution, but I still have this last major decode challenge to get through.

    Any help anyone can give me would be much appreciated.

    I have to say that the journey I have been on with this project has been frustrating at times, but when I look back, I have learned so very much it has certainly been worth the investment.

    Thanks to everyone that has helped me so far.

    Best regards,

    Mike
    Saratoga Springs, NY
Sign In or Register to comment.