Menu

Joining different port pins as a variable?

Help
2018-01-30
2018-01-31
  • David Thompson

    David Thompson - 2018-01-30

    Is it possible to somehow define 2 ports e.g. PortA.1 & PortA.2 with 2 from another e.b. PortB.1 & PorB.2
    so that they could be treated like a variable nibble? E.g.
    "What Ever the Compination is called" = 0b0101

    If not, can Symbols be stacked on one line? I guess I should just try this rather than ask, but while I'm here.
    E.g.

    define PA1 porta.1 'same for the other 3

    PA1=0 ,PA2=1,PB1=0,PB2=1

     
    • Anobium

      Anobium - 2018-01-30

      I dont understand the qestion. :-) So, give it a go! :-)

      But, can Symbols be stacked. try the line below but there adds no value... just put each one on a new line.

      #define pa1 0: #define pa2 1:#define pa2 1
      
       
  • Chris Roper

    Chris Roper - 2018-01-30

    Not as a native GCBasic function but you should be able to do it with a Macro:

    macro SetBits (VPort, VPin3, VPin2, VPin1, VPin0)
      Rotate VPort Right
      VPin0 = STATUS.C
      Rotate VPort Right
      VPin1 = STATUS.C
      Rotate VPort Right
      VPin2 = STATUS.C
      Rotate VPort Right
      VPin3 = STATUS.C
    end Macro
    

    Vport is your Variable, VPin0 ..VPin3 are the Physical Port Pins you want to use.

    So you example would be:

    Vport = 0b0101
    SetBits (VPort, PortB.2, PortB.1, PortA.2, PortA.1)

    I am not home so it is untested but should set you on the path.
    If you needed to read into yor virtual Port the Macro would be:

    macro GetBits (VPort, VPin3, VPin2, VPin1, VPin0)
      STATUS.C = VPin3
      Rotate VPort Left
      STATUS.C = VPin2
      Rotate VPort Left
      STATUS.C = VPin1
      Rotate VPort Left
      STATUS.C = VPin0
      Rotate VPort Left
      VPort = VPort & 0x0F
    end Macro
    

    If I get a chance later I will test them myself.

    Cheers
    Chris

     
  • David Thompson

    David Thompson - 2018-01-30

    Thanks Chris that looks promising, I think I understand it too!
    I would have to run the Macro for every line though, that's a lot of extra MicroC work and I'm using delays between steps to vary the speeds of 2 x stepper motors.
    I was using PortA to drive 2x stepper motors but I had to increase the chip speed to use uS. The added xtal took away Ports 6&7 so rather than redesigning the pcb, I was looking for a software fix.
    Designing the carriage before the horses arrived!
    Maybe I should redesign I'm only on the Mk3 version! I'm slowly being sucked into the sub world of SMD, only Caps, Resistors, Vregs and Motor controllers so far! Those 0.75mm traces or less, really intimidate me!
    Because I'm doing a lot of variations in motor directions as in Motor1 CW, Motor2 CWW etc, etc. I was trying to keep the number of lines down just for tidyness and ease of reading.

     
    • Chris Roper

      Chris Roper - 2018-01-30

      What processor are you using?
      You will probably be able to get a newer chip with 32Mhz internal Clock and
      the same footprint.
      It would mean resoldering the chip but not redesigning the whole PCB like a
      Xtal would.

      On 30 January 2018 at 20:27, David Thompson datman@users.sourceforge.net
      wrote:

      Thanks Chris that looks promising, I think I understand it too!
      I would have to run the Macro for every line though, that's a lot of extra
      MicroC work and I'm using delays between steps to vary the speeds of 2 x
      stepper motors.
      I was using PortA to drive 2x stepper motors but I had to increase the
      chip speed to use uS. The added xtal took away Ports 6&7 so rather than
      redesigning the pcb, I was looking for a software fix.
      Designing the carriage before the horses arrived!
      Maybe I should redesign I'm only on the Mk3 version! I'm slowly being
      sucked into the sub world of SMD, only Caps, Resistors, Vregs and Motor
      controllers so far! Those 0.75mm traces or less, really intimidate me!
      Because I'm doing a lot of variations in motor directions as in Motor1 CW,
      Motor2 CWW etc, etc. I was trying to keep the number of lines down just for
      tidyness and ease of reading.


      Joining different port pins as a variable?
      https://sourceforge.net/p/gcbasic/discussion/579126/thread/8fc45b6b/?limit=25#31d9


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/gcbasic/discussion/579126/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • mmotte

    mmotte - 2018-01-30

    David,
    Have you considered step and direction motor drivers like the A4988 Stepper Motor Driver Module? All the hard stuff is done.

    BR
    M

     
  • David Thompson

    David Thompson - 2018-01-31

    hi mike
    Still need to send the steps though. I'm using 4 x 9110 smd.
    Anyway I've sorted it out a different way.
    Thanks anyway.
    I've re designed the pcb to take ATmega48/88, the pin outs are much better for this application.
    I can fit a Xtal and have easy access to a complete port.

     

    Last edit: David Thompson 2018-02-05

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.