Shop OBEX P1 Docs P2 Docs Learn Events
Can anyone help me .... — Parallax Forums

Can anyone help me ....

XtremeXtreme Posts: 8
edited 2006-04-26 11:06 in General Discussion
Hello,

I want to make a code in the sx key for a 16bit and 8bit calculator doing multiplication, division, addition, substraction. The problem is that i don not know how to set the wires and the buttons to make it work. I did the code i do not know if is right.

I hope there is someone who can help me.


Thank You

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-20 05:19
    You haven't provided any code or circuit diagram to show what you have.· Without an idea of what you have, nobody is going to be able to do much to help you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • PJMontyPJMonty Posts: 983
    edited 2006-04-20 07:15
    Chris (or really Jon, I guess),

    Is there a sample in the SX/B help file of multiplexing buttons or wiring up a keypad? If not, might be good to add. I think it might but what Xtreme is looking for, but I'm not sure.
      Thanks, PeterM
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-20 14:03
    There is indeed -- it's something I translated to SX/B from one of our old PIC application books. It is in the sample projects section of the help file.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-04-20 14:42
    The SX Website has a whole section on doing math on the SXes.

    If you want Assembler rather than SX/B level code, you really don't have to start completely from scratch as there is quite a bit already available.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • XtremeXtreme Posts: 8
    edited 2006-04-20 16:45
    hello, guys

    Thank you for trying to help me. At this time i am not at home and i cannot send you the code, I will within 24 hours. What i want to do is to write an assebler code for a programmable calculator. I do not know how to set the wires and the buttons on the board. ·My board is the SX Tech Board.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-04-20 17:16
    Try looking at 'The I/O expander' at www.njgrp.org/oix/ for what a keyboard and LCD display involve. While this was written for an SX-28, it could easily be modified to an SX-48. In that way, you would have twice the RAM for number crunching.

    IMHO, an RPN calculator would be quite interesting and I think the stack approach would be very easy to impliment. A 4x4 keypad would provide you the function keys along with the number keys.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • XtremeXtreme Posts: 8
    edited 2006-04-20 20:01
    hello Kramer,

    I tried the side you are giving me, but it says that there is no such site.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2006-04-21 09:31
    Oh!!· IOX, not 'oix' in the address.·

    Do take a look as the code is public and it is a very good beginning.

    Dyslexia is taking hold.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • XtremeXtreme Posts: 8
    edited 2006-04-21 16:23
    there is another one mistake in the address, you put g instead of q, the correct address is http://www.njqrp.org/iox/
  • XtremeXtreme Posts: 8
    edited 2006-04-21 23:54
    Hello guys

    I entered the code here (that s the 8- bit calc for addiotiuona na dsubtraction )

    device SX28L, OSCHS,TURBO
    reset start_point
    freq 4000000                   ;4Mhz resonator
    
             org    8
    addend         ds    1
    adder        ds    1
    Sum        ds    1
    Subtrahend    ds    1    
    subtractor    ds    1    
    difference    ds    1    
    X        ds    1
    
    org       0 
    start_point      mov     !ra,#$f                        mov      !rb,#$ff
     
    ; begin code on page 0
    ; all of port A lines are input
    ; all of port B lines are output
     
    ; main program starts here
    arithloop    mov     Addend,#137  ; Addend value
    mov     X,Addend
    call      output    ; display Addend
     
    mov    Adder,#27
    mov    X,Adder
    call    output
    mov    Sum,Addend
    add    Sum,Adder
    mov    X,Sum
    call    output
     
    ; Adder Value
    ; display Adder
    ; first value in Sum ; perform addition ; display Sum
     
    mov    Subtrahend,^ 37    ; Subtrahend value
    mov    X,Subtrahend
    call    output    ; display Subtrahend
    mov    Subtractor,#27; Subtracter Value
    mov    X, Subtracter
    call    output    ; display Subtracter
     
    mov     Difference,Subtrahend sub      Difference,Subtractor
     
    ; first value in Difference ; perform subtraction
     
    mov     X,Difference   ; display Difference
    call      output
    jmp      arithloop    ; start again
    ; The subroutine defined below displays the value contained in X at LEDs attached to all
    :    lines of Port B
    output
    mov    W,X
    ; invert the bits, l's complement
    not    W
    mov    rb,W
    ra0ontest      ras0offtest ralontest raslofftest
    jb    ra.0,ra 0ontest
    jnb    ra.0,ra 0offtest
    jb    ra.l,ra l ontest
    jnb    ra.l,ra l offtest
    ret
    
    
  • BongoBongo Posts: 65
    edited 2006-04-22 08:27
    Hi xtreem,

    please be aware that going through other peoples code is a tedious and thankless task.

    In this case there is a rather obvious lack of attention by it's creator.

    If you try to assemble this, the assembler will point out quite a few errors.

    Perhaps you could attend these first?

    The patience and diligence of regular contributors to this forum never ceases to·amaze me, they·should be regarded as·a highly valued resource, in my opinion.· Please do not contibute to their burnout.

    bongo

    ·
  • XtremeXtreme Posts: 8
    edited 2006-04-22 20:11
    hello,

    sorry for the mistakes the code had, thats the correct code

    device SX28L, OSCHS,TURBO
    reset start_point
    freq 4000000                   ;4Mhz resonator
    
             org    8
    addend         ds    1
    adder        ds    1
    Sum        ds    1
    Subtrahend    ds    1    
    subtractor    ds    1    
    difference    ds    1    
    X        ds    1
    
             org       0     ; begin code on page 0
    start_point      mov     !ra,#$f    ; all of port A lines are input              
               mov     !rb,#$ff   ; all of port B lines are output
     
    ; main program starts here
    arithloop    mov     Addend,#137  ; Addend value
            mov     X,Addend
            call      output    ; display Addend
     
            mov    Adder,#27    ; Adder Value
            mov    X,Adder
            call    output         ; display Adder
            
            mov    Sum,Addend    ; first value in Sum  
            add    Sum,Adder    ; perform addition
            mov    X,Sum
            call    output    ; display Sum
     
    
    
    
     
            mov    Subtrahend, #137    ; Subtrahend value
    
            mov    X,Subtrahend
            call    output    ; display Subtrahend
    
            mov    Subtractor,#27; Subtracter Value
            mov    X, Subtractor
            call    output    ; display Subtracter
     
            mov     Difference,Subtrahend ; first value in Difference
            sub      Difference,Subtractor     ; perform subtraction
     
     
    
            mov     X,Difference   ; display Difference
            call      output
            jmp      arithloop    ; start again
    
    ; The subroutine defined below displays the value contained in X at LEDs attached to all
    ;    lines of Port B
    output      mov    W,X   
            not    W  ; invert the bits, l's complement
            mov    rb,W
    ra0ontest         jb      ra.0,ra0ontest
    ra0offtest    jnb    ra.0,ra0offtest
    ra1ontest     jb    ra.1,ra1ontest
    ra1offtest     jnb    ra.1,ra1offtest
            ret
    
    
  • BeanBean Posts: 8,129
    edited 2006-04-22 20:50
    This line mov !rb,#$ff ; all of port B lines are output
    Should be mov !rb,#$00 ; all of port B lines are output

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video·Module"·available from Parallax for only $28.95 http://www.parallax.com/detail.asp?product_id=30012


    "SX-Video OSD module"·available·for only·$49.95·www.sxvm.com
    Available now! Cheap 4-digit LED display with driver IC·www.hc4led.com

    "I reject your reality, and substitute my own." Mythbusters
    ·
  • BongoBongo Posts: 65
    edited 2006-04-22 23:02
    Ok,

    The next step is to program an SX and debug, or load this into Gunther's SX sim. With either of these tools you can step through the program and see exactly what the SX is doing and therefore learn and fix any errors.

    A lot of time must have gone into developing these tools, take advantage of them. I wonder why Gunther would go to the trouble of SX sim, and then give it away? One assumes he must be completely mad.

    You will never (and you may quote me on this) get anything worthwhile running without debug or SX sim. Learning how to use them is not optional.

    The good news is that this will not take you long. At first appearances you may have started with something a bit simpler, but the 8 bit math is good.

    bongo
  • XtremeXtreme Posts: 8
    edited 2006-04-23 02:01
    here is the thing,

    The problem i have is that i do not know how to set the wires in the board. However that code has the input number already. What i really want is to put a dip switch and so the user will input the numbers he/she wants and get the results.

    Thank You
  • BongoBongo Posts: 65
    edited 2006-04-23 08:24
    Hi Extreme,

    At the bottom of this page: http://www.parallax.com/sx/index.asp you will find an offer of a free book download. I think you will find everything you need plus more in there.

    Have also noticed people that buy a kit that includes Gunther's book highly recommend it. (Gunther's book)

    There has been a lot of material written specifically for the purposes of getting started. And there is also a logical progression in those tutorials that you can not get from this discussion group.

    Go look 'em up. As you may have noticed, I am not going to directly answer your questions, even if I was clear about what they are. I cannot, because I know if we go down that road, your questions will never end. They will just get more sophisticated. You need to familiarize yourself with the resources that have already been placed, all over this website.

    Good luck and concentrate grasshopper...............


    bongo
  • pjvpjv Posts: 1,903
    edited 2006-04-23 22:55
    Well said Bongo.

    Cheers,

    Peetr (pjv)
  • John KauffmanJohn Kauffman Posts: 653
    edited 2006-04-25 16:32
    If this is a learning exercise, then great.
    If you want quick results, look at http://www.parallax.com/detail.asp?product_id=604-00030a
  • XtremeXtreme Posts: 8
    edited 2006-04-25 17:52
    Thank You John,

    I will first try with the one i have
  • DigitalDjDigitalDj Posts: 207
    edited 2006-04-26 00:07
    Bongo,

    I totally have to disagree wih your comments sounds like a college professor i once had. Some people just need that one little hump to get over in the beginning and then thier off running. Maybe he doesn't have a lifetime to search all over the forum or website, which by the way is not the easiest to navigate. They way i look at it is you may learn something from his questions, trials and tribulations, if you don't ever learn from someone else in life then you must be a god. I am one that is also a newbe and just remember·we have all·been there too, at least he has tried. At work I get alot of enjoyment out of training coworkers and when they have grasped a certain situation or a piece of equipment then there's alot of job staisfaction. I also teach them what has worked best for me and let them decide if it works good for them or not.

    Kudos to John, Bean and everyone else with a positive attitude to help!

    Kevin




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Post Edited (DigitalDj) : 4/26/2006 12:29:29 AM GMT
  • PJMontyPJMonty Posts: 983
    edited 2006-04-26 11:06
    Kevin,

    This is one of those things that cuts both ways. It's pretty clear that Xtreme didn't even assemble his code the first time he posted it because it won't even assemble as it was written. When someone hasn't even taken care of step one (making sure the code will assemble), it tends to put people off wanting to help. If he wanted help with explaining why he was getting error messages, that would be one thing, Instead, it was simply posted with a "Here you go forum people" kind of message, leaving you to assume that he wanted members here to debug and correct his code. That's just not the way it works. At some point, beginners have to do some of the work.

    In addition, Xtreme has stated a couple of times that he "doesn't know how to set the wires in the board". First, I think that English is a second language for Xtreme, so that's always a challenge for both sides. Second, his statement is incredibly vague (see previous sentence), which makes it hard for anyone to figure out what is being asked. Third, in my post on 4/20, I specifically take a guess at what Xtreme wants and Jon offers up that a sample is available. However, Xtreme never once commented on this to say if the guess was wrong and provide clarification of what he meant, or to thank anyone if it was right. This also makes people less interested in helping.

    Folks here try to help out as much as possible, but so often the people who post come with an attitude that as long as they have done some bare minimum amount of work that the forum should leap to their feet and do the rest for them. I am not saying that Xtreme is necessarily doing that, but it feels dangerously close. Perhaps this is the language barrier (if I'm right about that), but once again, this tends to put most people off being willing to help.

    Finally, you mention that, "Maybe he doesn't have a lifetime to search all over the forum or website." Well, lets put the shoe on the other foot. If he doesn't have the time to search, what makes him or you or anyone think that the rest of us have the time to do it for him? Nothing is more frustrating than someone who can't or won't do even the most rudimentary Google search for answers, and that is something I see all too often on the forums. Remember, all the help given here is voluntary, so the folks asking for help need to bend over backwards, not the folks giving the answers.

    I agree that we should all have a positive attitude, but I think you missed the point of Bongo's post completely. I think Bongo's post has an extremely positive attitude. It wasn't a "Let me change your diaper and tuck you into bed" attitude, but more of a "It's time for you to learn how to use the free resources at hand and then come back with more specific questions" attitude. Showing that you have tried and failed before asking for help gets a lot more respect than coming to the forum and just saying, "Teach me everything I need to know." Bongo is trying to nudge Xtreme into the "More Respect" category.
      Thanks, PeterM
Sign In or Register to comment.