Shop OBEX P1 Docs P2 Docs Learn Events
elctronics questions on new project — Parallax Forums

elctronics questions on new project

cvtcvt Posts: 6
edited 2005-01-02 07:26 in BASIC Stamp
just as an intro, I'm pretty fluent in basic, and not real good at electronics.
But I am in a rushed to be built project, and need some help, as I have ran out of pins.

My pins are currently assigned.

0 - sensitivity/more (INPUT)
1 - sensitivity/less (INPUT)
2 - solenoid/lower (OUTPUT)
3 - solenoid/lift (OUTPUT)
4 - adc1/cs
5 - adc1/clk
6 - adc1/data
7 - lcd/serial (OUTPUT)
8 - autocontrol/off (INPUT)
9 - autocontrol/on (INPUT)
10 - adc2/cs
11 - adc2/clk
12 - adc2/data
13 - adc3/cs
14 - adc3/clk
15 -adc3/data

now, my issue is with the operation of the automatic ON/OFF
I could use it as a momentary switch to turn it on, momentary off
but when one part of the machine is operated, if the button is tapped, and not held, it must deactivate the auto.
if I run it with the autocontrol/off line, one in every 4 or 5 times I tapped it, it didn;t register due to the amount of code/datain/dataout in one loop.
I can't put a D Flip-Flop in there, because I'd need an extra line to manipulate the CLK

My question is, as all 3 ADC's are identical, could I make the CLK line on the common across all 3, freeing me up 1 line, is it also possible to do this with the cs line.

Read_ADC1:
LOW adc1_cs
SHIFTIN  adc1_dio, adc1_clk, MSBPOST, [noparse][[/noparse]adc1\8]   <---- yes, 7 bit resolution intentionally
HIGH adc1_cs
RETURN




thats all I have for reading the adc's, it just goes from one to the next adc in a row.
with the shift high, shift low, between each read would be too fast for the ADC's to reset, or would it, this is where I am currently stuck.

I'm using a BS2e
my ADC is NatSemi ADC0831

Comments

  • cvtcvt Posts: 6
    edited 2004-12-31 08:17
    nevermind, I optimized the code a bit, running fastenough now it doesn't seem to be an issue anymore, and I have it checking the OFF line twice in the total loop aswell after that to make sure.

    my button code, incase anyone is curious is

    buttondetect:
    IF IN0 = 1 THEN inzero
    IF IN1 = 1 THEN inone
    lastin0 = 0
    lastin1 = 0
    skipbutton:
    RETURN
    
    
    inzero:
    IF lastin0 = 1 THEN skipbutton
    lastin0 = 1
    GOSUB sens_more
    RETURN
    
    inone:
    IF lastin1 = 1 THEN skipbutton
    lastin1 = 1
    GOSUB sens_less
    RETURN
    
  • allanlane5allanlane5 Posts: 3,815
    edited 2004-12-31 12:54
    You can 'share' the ADC Clock line between three ADC's, and the Data line the same way. As long as the ChipSelect is unique to each chip, that is. This would save you 4 pins.
  • DonDon Posts: 34
    edited 2004-12-31 16:22
    allanlane5 said...
    You can 'share' the ADC Clock line between three ADC's, and the Data line the same way. As long as the ChipSelect is unique to each chip, that is. This would save you 4 pins.
    And you can save one more line if you add an external·2 to 4 line decoder to produce·the chip selects.· It sounds like you don't need to·do that on this project but it's a technique to keep in mind for future projects.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Don Kinzer

    ·
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-12-31 18:51
    This article will show you how to share clock and data lines safely: http://www.parallax.com/dl/docs/cols/nv/vol3/col/nv81.pdf

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • cvtcvt Posts: 6
    edited 2005-01-02 07:26
    Thanks a lot for the replys.
    Very helpful!
Sign In or Register to comment.