Shop OBEX P1 Docs P2 Docs Learn Events
Shiftin — Parallax Forums

Shiftin

ArchiverArchiver Posts: 46,084
edited 2003-10-28 13:47 in General Discussion
I am trying to shiftin 52 synchronous bits from a mitutoyo digital
depth mic. The depth mic provides a clock and 52 bits. The Basic
stamp only needs to pull a request line low to start the
transmission. I am having trouble recieving this information with
shiftin because it allows for an internal clock only.

Is there any way around this? I have tried to write a loop to
recieve the data, but the BS2p40 doesn't execute code fast enough to
keep up with the external clock that is running at ~3.0Kbs.

thanks
mike Dolan
NJ

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2002-08-14 18:25
    Hi Mike,

    The SHIFTIN command is made for synchronous devices, which give their own
    clock.
    I think 3 Kbps is not too fast for the Stamp. Check the mode value to be
    sure that the bits to be transmited are at a stable state when the sampling
    occurs.
    Does the Mitutoyo send all 52 bits in one shot ?

    Phil.

    Original Message
    From: "lightningshack" <MikDolan54@a...>
    To: <basicstamps@yahoogroups.com>
    Sent: Wednesday, August 14, 2002 5:52 PM
    Subject: [noparse][[/noparse]basicstamps] SHIFTIN


    > I am trying to shiftin 52 synchronous bits from a mitutoyo digital
    > depth mic. The depth mic provides a clock and 52 bits. The Basic
    > stamp only needs to pull a request line low to start the
    > transmission. I am having trouble recieving this information with
    > shiftin because it allows for an internal clock only.
    >
    > Is there any way around this? I have tried to write a loop to
    > recieve the data, but the BS2p40 doesn't execute code fast enough to
    > keep up with the external clock that is running at ~3.0Kbs.
    >
    > thanks
    > mike Dolan
    > NJ
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-08-14 19:00
    Phil,

    If shiftin is made for devices which give there own clock. Then
    maybe the manual is confusing me? Why does it read?

    Cpin is a variable/constant/expression(0-15) that specifies the I/O
    pin that will be connected to the synchronous serial device's clock
    input. This pin will be set in output mode.

    If it were setup to recieve a clock signal I would imagine it would
    be set up in input not output mode.

    Yes, the mitutoyo device simultaniously sends out 52 clk and data
    pulses, and the microprocessor is supposed to read the data on the
    rising or falling edge of the clock pulses.

    When I couldn't set ShiftIN to recieve clock pulses I decided to
    write a loop. Where in1 is the data, and IN2 is the clk from the
    depth mic.

    'for counter = 0 to 51
    'Again:
    'IF IN2 = 1 then Again
    'rawdata(counter) = IN1
    'NEXT

    This is not working and I think it's because the processor can't keep
    up. At 10,000 lines/sec these 4 lines will take approximately .0004
    seconds, and the 52 bits are coming out in 16ms as measured on my
    scope and confirmed on the mitutoyo datasheet. The loop needs to
    execute 52 times to recieve the data, 52x.0004sec is a 20ms, this is
    is a longer period then the 16ms that it takes for all of the pulses
    to come out.

    I know the signal is stable because I am watching it on an Analog
    scope.

    what do you think
    mike





    --- In basicstamps@y..., "Philippe Derenne" <derennep@b...> wrote:
    > Hi Mike,
    >
    > The SHIFTIN command is made for synchronous devices, which give
    their own
    > clock.
    > I think 3 Kbps is not too fast for the Stamp. Check the mode value
    to be
    > sure that the bits to be transmited are at a stable state when the
    sampling
    > occurs.
    > Does the Mitutoyo send all 52 bits in one shot ?
    >
    > Phil.
    >
    >
    Original Message
    > From: "lightningshack" <MikDolan54@a...>
    > To: <basicstamps@y...>
    > Sent: Wednesday, August 14, 2002 5:52 PM
    > Subject: [noparse][[/noparse]basicstamps] SHIFTIN
    >
    >
    > > I am trying to shiftin 52 synchronous bits from a mitutoyo digital
    > > depth mic. The depth mic provides a clock and 52 bits. The
    Basic
    > > stamp only needs to pull a request line low to start the
    > > transmission. I am having trouble recieving this information
    with
    > > shiftin because it allows for an internal clock only.
    > >
    > > Is there any way around this? I have tried to write a loop to
    > > recieve the data, but the BS2p40 doesn't execute code fast enough
    to
    > > keep up with the external clock that is running at ~3.0Kbs.
    > >
    > > thanks
    > > mike Dolan
    > > NJ
    > >
    > >
    > > To UNSUBSCRIBE, just send mail to:
    > > basicstamps-unsubscribe@y...
    > > from the same email address that you subscribed. Text in the
    Subject and
    > Body of the message will be ignored.
    > >
    > >
    > > Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
    > >
    > >
  • ArchiverArchiver Posts: 46,084
    edited 2002-08-14 19:21
    Mike,

    Oops, I was a little bit too fast...
    Whit SHIFTIN, the Stamp is giving the clock to the serial device, so Cpin is
    an output (synchronous data transfert).

    So, if the serial device is the 'clock master', it is *asynchronous* data
    transfert (on Stamp's point of view), and you must use SERIN.
    Then, you must know and/or set the baudrate of the Mitutoyo. Let's say 9600
    baud. You have to use the right baudmode for this speed, and the Stamp must
    be 'listening' when data goes out of the Mitutoyo. You may put the SERIN
    command into a waiting loop.

    Would this be more helpfull ?

    Phil.


    Original Message
    From: "lightningshack" <MikDolan54@a...>
    To: <basicstamps@yahoogroups.com>
    Sent: Wednesday, August 14, 2002 8:00 PM
    Subject: [noparse][[/noparse]basicstamps] Re: SHIFTIN


    > Phil,
    >
    > If shiftin is made for devices which give there own clock. Then
    > maybe the manual is confusing me? Why does it read?
    >
    > Cpin is a variable/constant/expression(0-15) that specifies the I/O
    > pin that will be connected to the synchronous serial device's clock
    > input. This pin will be set in output mode.
    >
    > If it were setup to recieve a clock signal I would imagine it would
    > be set up in input not output mode.
    >
    > Yes, the mitutoyo device simultaniously sends out 52 clk and data
    > pulses, and the microprocessor is supposed to read the data on the
    > rising or falling edge of the clock pulses.
    >
    > When I couldn't set ShiftIN to recieve clock pulses I decided to
    > write a loop. Where in1 is the data, and IN2 is the clk from the
    > depth mic.
    >
    > 'for counter = 0 to 51
    > 'Again:
    > 'IF IN2 = 1 then Again
    > 'rawdata(counter) = IN1
    > 'NEXT
    >
    > This is not working and I think it's because the processor can't keep
    > up. At 10,000 lines/sec these 4 lines will take approximately .0004
    > seconds, and the 52 bits are coming out in 16ms as measured on my
    > scope and confirmed on the mitutoyo datasheet. The loop needs to
    > execute 52 times to recieve the data, 52x.0004sec is a 20ms, this is
    > is a longer period then the 16ms that it takes for all of the pulses
    > to come out.
    >
    > I know the signal is stable because I am watching it on an Analog
    > scope.
    >
    > what do you think
    > mike
    >
  • ArchiverArchiver Posts: 46,084
    edited 2002-08-14 19:32
    The BASIC Stamp provides the clock for both SHIFTIN and SHIFTOUT. It is
    setup to be a master; not a slave.

    -- Jon Williams
    -- Parallax

    In a message dated 8/14/02 12:26:47 PM Central Daylight Time,
    derennep@b... writes:


    > The SHIFTIN command is made for synchronous devices, which give their own
    >




    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2002-08-15 13:46
    Tracy,

    thanks for the help, that CD4031 might just do the trick..


    mike
  • ArchiverArchiver Posts: 46,084
    edited 2003-10-28 13:47
    Hello All,

    Can anybody translate this porgram to use a command other then
    SHIFTIN. I am looking to avoid using SHIFTIN and maybe use PULSIN,
    is that possible?

    I am eading MAX187 ADC values

    Thanks

    Yossi

    '{$STAMP BS2}

    sclk CON 5
    cs CON 6
    serdata CON 7
    adc VAR Word

    main:
    GOSUB convert
    GOSUB print
    PAUSE 500
    GOTO main

    print:
    DEBUG DEC adc,CR
    RETURN

    convert:
    LOW cs
    SHIFTIN serdata,sclk,MSBPOST,[noparse][[/noparse]adc\12]
    HIGH cs
    RETURN
Sign In or Register to comment.