Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Hardware & Devices
  4. Serial Int Question [modified]

Serial Int Question [modified]

Scheduled Pinned Locked Moved Hardware & Devices
question
23 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N NormDroid

    I have a serial interface on a device with 6 pins: 1 NC 2 0v 3 +12v 4 SClk 5 SData 6 0v Now I want to wire this to a serial Port on a PC, I have wired the 12v and 0v to a molex, but I need to work out were to wire SClk and SData, I'm guessing (on previous experience) that I should be wiring SClk to DTR and SDATA to RX on the RS232. I'm I warm or completely cold. BTW: The 12v and 0v and input supply voltages. -- modified at 9:02 Thursday 9th August, 2007 -- modified at 9:07 Thursday 9th August, 2007

    Roger Irrelevant "he's completely hatstand"

    C Offline
    C Offline
    cp9876
    wrote on last edited by
    #21

    Just reading this thread it appears that you want to interface to an I2C device. For simply writing to the device, it is pretty easy to do this using the PC parallel port. I have intefaces to many ICs that use this interface in this manner. It is even easier if you have an old PC running Win98, as there you could simply write to the parallel port using an OUT instruction. On OSs based on NT (i.e. Win2k and XP), you need a device driver. To give you an idea, here is a code snippet synchronously clocking n bits of data out of hte parallel port on a Win98 machine:

    const int PORT = 0x378; // base address of LPT1 on

    const char ENABLE = 1; // syn enable PC Pin # 2
    const char CLOCK = 2; // syn clock PC Pin # 3
    const char DATA = 4; // syn data PC Pin # 4

    char state;

    void OutputP(long data, int n, bool bSync)
    {
    // take enable low
    state &= ~ENABLE;

    outp(PORT, state);

    long current_bit = pow(2,n-1);

    for (int i = 0 ; i < n ; i++)
    {
    // set data bit
    if (data & current_bit)
    state |= DATA;
    else
    state &= ~DATA;
    // output data bit
    outp(PORT, state);

     // clock it
     state |= CLOCK;
     outp(PORT, state);
    
     state &= ~CLOCK;
     outp(PORT, state);
    
     current\_bit /= 2;
     }
    

    // take enable high
    state = ENABLE; // ensures all other lines are low
    if (bSync)
    state |= SYNC;
    outp(PORT, state);
    }

    depending on the speed of your PC you may need some delays to slow down the clocking.


    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    1 Reply Last reply
    0
    • N NormDroid

      Thanks Margret ;)

      Roger Irrelevant "he's completely hatstand"

      L Offline
      L Offline
      LittleYellowBird
      wrote on last edited by
      #22

      Hi Norm, I came across this today and as they say "I thought of you", its an I2C USB Interface! I bet not many women have said that to you! :-D http://www.elektor.com/default.lynkx?pointer=1-28-16120-16357-16368-26623 Anyway, I had to pass it on in case it might be handy ..... Cheers,

      Ali

      N 1 Reply Last reply
      0
      • L LittleYellowBird

        Hi Norm, I came across this today and as they say "I thought of you", its an I2C USB Interface! I bet not many women have said that to you! :-D http://www.elektor.com/default.lynkx?pointer=1-28-16120-16357-16368-26623 Anyway, I had to pass it on in case it might be handy ..... Cheers,

        Ali

        N Offline
        N Offline
        NormDroid
        wrote on last edited by
        #23

        Alison Pentland wrote:

        I came across this today and as they say "I thought of you", its an I2C USB Interface! I bet not many women have said that to you!

        Oh you're just one of millions ;) Had a look: articles date around 2004, there are newer ones, I'm just about buy a device under £20 USB->IC2, apparently these things are getting popular, whats needed is somebody to design a board and manufactor in China and bingo $$$. Sell for under £10 including an API:~ -> Norm <-

        Roger Irrelevant "he's completely hatstand"

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups