Shop OBEX P1 Docs P2 Docs Learn Events
question about the capabilities of the atmel attiny13 on the bs2pe board — Parallax Forums

question about the capabilities of the atmel attiny13 on the bs2pe board

andreiuandreiu Posts: 4
edited 2010-01-26 23:24 in BASIC Stamp
hy

i am new here ...i am working on making 2 IR detectors (Sharp GP2D12) interface with my bs2pe motherboard using daughtercard B

from the gpio firmware manual there is nothing mentioned about using the integrated analog to digital converter on analog input 0 and 1 at the same time.Can it be done?
I would like not to use the other coprocessor for the second IR sensor as it's occupied doing something else (driving a 7 segment LCD )


IF anyone can help me i would be more than grateful

PS: sorry for my english if , at times , my way of describing things is akward...

Thank You

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-01-18 15:58
    The ATTiny13 can do one analog to digital conversion at a time on either analog input 0 or analog input 1. You could alternate, first input 0, then input 1, then repeat. That should be fast enough.
  • andreiuandreiu Posts: 4
    edited 2010-01-26 10:33
    hy mike - thank you for your help. I thought of that thing exactly - doint the sampling by turn ...
    here is my sampling code ...please help me modify it to do alternative sampling on both input analog ports 0 and 1 because i had no luck trying to modify it

    senzor_stg VAR Word          'VARIABLE THAT CONTAINS DATA FROM IR LEFT 
    senzor_dr VAR Word           'VARIABLE THAT CONTAINS DATA FROM IR RIGHT
     Busy    VAR Bit
    OWOUT 6, 0, [noparse][[/noparse]%00001111]     
     DO : OWIN 6, 4, [noparse][[/noparse]Busy] : LOOP WHILE Busy     
    
    OWIN 6, 0, [noparse][[/noparse]senzor_dr.HIGHBYTE, senzor_dr.LOWBYTE]
    
    
    
        PAUSE 500
    
    DEBUG ?senzor_dr
    
           
    
    
    


    thank you again...hope you can help me sort this out...because it's not long before i have to finish my degree paper...

    Ps: also cand you please tell me where i can find a more detailed description of gpio firmware commands- i cannot fully understand the arguments between owio and [noparse][[/noparse]%...], i mean the first and second argument (numbers)

    Post Edited (andreiu) : 1/26/2010 10:38:05 AM GMT
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-01-26 17:12
    Here's a link to the GPIO3 manual, as found on the MoBoStamp-pe product page:

    ····www.parallax.com/Portals/0/Downloads/docs/prod/boards/28300-AVR_GPIO-3-0906.PDF

    -Phil
  • andreiuandreiu Posts: 4
    edited 2010-01-26 17:14
    thanks phil , i have that documentation already , but it is not clear enough in their description
  • sylvie369sylvie369 Posts: 1,622
    edited 2010-01-26 17:30
    andreiu said...
    Ps: also cand you please tell me where i can find a more detailed description of gpio firmware commands- i cannot fully understand the arguments between owio and [noparse][[/noparse]%...], i mean the first and second argument (numbers)
    It is complicated, because the information that you need is found in three separate places. The immediate answer to the question that you just asked is that you need to look at the PBasic Help file's page on the OWIN and OWOUT commands. For example, in OWOUT, you'll find
    PBASIC doc said...
    The 1-Wire protocol is a form of asynchronous serial communication developed by Maxim/Dallas Semiconductor. It only requires one I/O pin and that pin can be shared between multiple 1-Wire devices. The OWOUT command allows the BASIC Stamp to send data to a 1-Wire device.

    The following is an example of the OWOUT command:

    OWOUT 0, 1, [noparse][[/noparse]$4E]

    This code will transmit a "reset" pulse to a 1-Wire device (connected to I/O pin 0) and then will detect the device's "presence" pulse and then transmit one byte (the value $4E).

    The Mode argument is used to control placement of reset pulses (and detection of presence pulses) and to designate byte vs. bit input and normal vs. high speed. The tables below show the meaning of each of the four bits of Mode and some of the 16 possible values and their effect.

    Mode Format bits

    attachment.php?attachmentid=73946
    Then you also need to look at the documentation for the BS2PE Mobo, which will show you which pins are attached to which of the Tiny13 co-processors in which way:
    Mobo doc guy said...
    Port Summary
    Port Description and Typical Use Daughterboard
    4.7K
    pullup?
    P0 General-purpose pin or SDA. B Yes
    P1 General-purpose pin or SCL. B Yes
    P2 General-purpose pin or poll input. A & B Yes
    P3 General-purpose pin or poll input. A & B Yes
    P4 Receive data echo enable. Pull low to disable echo. (none) Yes
    P5 General-purpose I/O. Shared with AVR “B”, port B3. B No
    P6 Communication port for coprocessor “B”. (none) Yes
    P7 General-purpose I/O. Shared with AVR “B”, port B2. B No
    P8 General-purpose pin or SDA. A Yes
    P9 General-purpose pin or SCL. A Yes
    P10 Communication port for coprocessor “A”. (none) Yes
    P11 General-purpose I/O. Shared with AVR “A”, port A2. A No
    P12 General-purpose I/O. Shared with AVR “A”, port A3. A No
    P13 Red LED. Pull low to turn on. (none) No
    P14 Green LED. Pull low to turn on. (none) No

    P15 Reserved for AVR programming. DO NOT USE! (none) No

    Finally you need to read the documentation of the GPIO firmware, as already noted, in order to understand the commands being sent. You should work through each of the examples in that document, referring back to the other two I mentioned, until you understand why they work as they do.
    278 x 308 - 6K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-01-26 17:47
    sylvie369,

    You bring up an interesting point about the scattering of documents needed to understand and use the coprocessors. Since I'm the guy who wrote the MoBo docs, could you suggest ways to make the subject more approachable for beginners?

    Thanks,
    -Phil
  • sylvie369sylvie369 Posts: 1,622
    edited 2010-01-26 18:34
    Ah, I asked for that, didn't I? smile.gif

    One key thing is that in the GPIO documentation, all of the Command Protocol·examples refer to a constant "Owio",·whose value is apparently declared elsewhere in your program - but not shown to the reader. For example, it begins (p.2) with

    OWOUT Owio, 0, [noparse][[/noparse]$25]

    and then says "this statement will write a digital 1 to port 2, causing it to go high". But of course you can't just type that command - it needs to know what Owio is.

    In the margins I have notes clarifying this for myself:

    -·I have an arrow coming from "Owio" reading "AVR Commport: 10 for DB'A', 6 for DB'B'" (which information I got from the "Port Summary" table on page 8 of the Mobo documentation).
    - Then I have an arrow from the '0' that follows that, reading "byte mode"·(which I got from the OWOUT help file in PBASIC). ·For the second example, I have an arrow going to a note reading "bit mode". I only figured that out when I realized that I had to look up the OWOUT command to understand the examples. It would be helpful to have had a comment (breakout box?) somewhere nearby pointing that out. In particular, the value of Owio is always 10 for coprocessor A and 6 for coprocessor B, right? It wouldn't take much to point that out, and then have a quite "see PBASIC documentation for OWOUT" to explain the "0" after the comma.
    I also think that example (the one above) is better than the one used on p.3 to illustrate the Digital Output command, simply because the example on p.3 has some confusing shift stuff in it. It's easier to understand that

    $25 means port 2, and then 5 = %0101 which means %010x (digital output) and x = 1 (set·high).

    You could have followed up with

    $24 means port 2, and then 4 = %0100, set port 2 low.

    In short, I really think that one little breakout box next to that first Command Protocol example would make a lot of difference. It took me some time to figure out what Owio should be, and why there's that 0 or 2 or whatever after the example.

    (by the way, I think that the way that the commands are defined in GPIO is a great illustration of why we use hex at times in computer science)


    Post Edited (sylvie369) : 1/26/2010 6:42:35 PM GMT
  • andreiuandreiu Posts: 4
    edited 2010-01-26 18:54
    sylvie369 pointed exactly my situation... thank you very much , you helped me out of a jam ...


    and ...can anyone help me modify the code in my previous post so that i can sample analog port 0 and 1 alternatively ?

    basically , i am using the A/D converter posibilities of the attiny13 microprocessor - but from my understanding i cannot sample both at the same time but sample them each like mike sugested
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-01-26 18:54
    sylvie369,

    Thanks for taking the time. That's a big help!

    -Phil
  • sylvie369sylvie369 Posts: 1,622
    edited 2010-01-26 23:24
    No problem. It was good for my brain to work through that stuff, and by the time I figured it out I started to believe I could move past the basics.

    Do you suppose Parallax might·be·interested in a part-time documentation editor? tongue.gif



    Andrieu - To sample the two ports alternatively, you should just figure out how to sample port 0, and then copy that code, but replace the address for port 0 with the address for port 1. The analog input command is described on p. 6 of the GPIO docs. There's an example on p.10, using %00001011, ($0B) which, as it explains, samples port 0 (as indicated by the upper four bits being all zeros). If you wanted to sample port 1 the same way, you'd just make the last of those four bits into a 1: %00011011 (which is $1B).

    If you're using Hex for your commands, you just make the first digit of the command a 0 for port 0, and a 1 for port 1. That's what I meant when I said that this is why we sometimes write things in Hex - it makes that kind of thing really obvious.
Sign In or Register to comment.