Answers.Body: <p>You are using the function run_target... which tells the motor to run to a specific angle.
  So it turns to an absolute position...</p>
  <p>This might be correct for the pen_up and pen_down cases, but I think that for the movement, you want relative movement, i.e. relative from your current position, hence I think the instruction you need is run_angle instead of run_target.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-13T13:02:07.783Z
Answers.LastActivityDate: 2020-12-13T13:02:07.783Z
Answers.UserDisplayName: Michael Verschaeve
Body: <p>I'm building an image printer using my ev3 set and several more pieces, as a project to keep me occupied while I'm stuck at home.</p>
  <p>Here's how it looks:</p>
  <p><a href="https://i.sstatic.net/wY26v.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/wY26v.jpg" alt="MOTORS ARE MARKED AS IN THE PROGRAM, PORTS ARE CORRECTLY SET" /></a></p>
  <p>I've done the build part, the way I've chosen to do this is by converting my image to binary (B/W) and reading each number in my binary array, then drawing a dot if there's a <em>1</em> or skipping the dot if there's a <em>0</em>.</p>
  <p>I'm using Ev3 Python, as that's the language I know and I found it easiest to program in, but after I created my program my brick doesn't seem to process it properly and my brick weirdly starts to draw dots in the same spot, then instantly starts to move its top arm in the same direction for much longer than its programmed to, then sort of just stops its paper-moving wheels and starts doing more weird movements.</p>
  <p>I tested my program's values before I wrote the program, it can draw 2 dots in a line correctly spaced out, but it starts doing weird things when I give it a whole line of data to draw.</p>
  <p>Here's my code:</p>
  <pre><code>#!/usr/bin/env pybricks-micropython
  from pybricks.hubs import EV3Brick
  from pybricks.ev3devices import Motor
  from pybricks.parameters import Port
  import time
  
  
  ev3 = EV3Brick()
  
  LR = Motor(Port.C)
  UD = Motor(Port.D)
  FB = Motor(Port.B)
  
  def pendown():
      UD.run_target(40, 40)
  def penup():
      UD.run_target(40, -40)
  def nextline():
      LR.run_target(40, 300)
      FB.run_target(40, 30)
  def nextdot():
      LR.run_target(40, -30)
  
  byteval = '''
  0000000000100100001001000000000000100100001111000000000000000000
  '''
  
  bytevalues = list(byteval)
  
  # wait a bit
  time.sleep(5)
  
  # define grid limit
  
  x_limit = 8
  y_limit = 8
  number_of_cells = x_limit * y_limit;
  x = 0
  # scan grid and perform action depending on cell value
  
  while x &lt; (number_of_cells):
      z = bytevalues[x]
      if z == '1': #draw a dot
          pendown()
          penup()
          nextdot()
      elif z == '0': #go to next cell value
          nextdot()
      x+=1
      if (x % x_limit) == 0: #go to next line
          nextline()
  </code></pre>
  <p>[I'm using an 8-Bit happy face as my image]</p>
  <p>I don't know why this weird movement is happening, I don't think it should, please help me with this issue.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-12T09:39:36.943Z
Comments.Text: Have you tried putting a sleep in your while loop ?
Comments.UserDisplayName: Michael Verschaeve
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-13T12:37:44.940Z
Comments.Text: I did, still isn't working
Comments.UserDisplayName: leaves
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-13T12:54:51.357Z
Comments.Text: Changed more values, now it drew 4 dots in a column? I'm very confused
Comments.UserDisplayName: leaves
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-20T17:03:09.697Z
Comments.Text: I think this question should be on Stack Overflow.
Comments.UserDisplayName: H. Pauwelyn
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-22T02:26:28.000Z
Comments.Text: It could be, but you need people familiar with EV3 and ev3python.
Comments.UserDisplayName: leaves
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-22T15:38:56.107Z
Comments.Text: You accepted my answer (green checkmark), does this mean it fixed your problem?
Comments.UserDisplayName: Michael Verschaeve
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-12-23T14:00:26.817Z
Comments.Text: Yeah, it solved my problem, thanks!
Comments.UserDisplayName: leaves
Tags: <ev3><programming><pybricks>
Title: Help with my Ev3 printer
UserDisplayName: leaves
ThreadText: # Help with my Ev3 printer
  
  (Asked by: username_0 on 2020-12-12)
  
  I'm building an image printer using my ev3 set and several more pieces, as a project to keep me occupied while I'm stuck at home.
  Here's how it looks:
  
  I've done the build part, the way I've chosen to do this is by converting my image to binary (B/W) and reading each number in my binary array, then drawing a dot if there's a 1 or skipping the dot if there's a 0.
  I'm using Ev3 Python, as that's the language I know and I found it easiest to program in, but after I created my program my brick doesn't seem to process it properly and my brick weirdly starts to draw dots in the same spot, then instantly starts to move its top arm in the same direction for much longer than its programmed to, then sort of just stops its paper-moving wheels and starts doing more weird movements.
  I tested my program's values before I wrote the program, it can draw 2 dots in a line correctly spaced out, but it starts doing weird things when I give it a whole line of data to draw.
  Here's my code:
  #!/usr/bin/env pybricks-micropython
  from pybricks.hubs import EV3Brick
  from pybricks.ev3devices import Motor
  from pybricks.parameters import Port
  import time
  
  
  ev3 = EV3Brick()
  
  LR = Motor(Port.C)
  UD = Motor(Port.D)
  FB = Motor(Port.B)
  
  def pendown():
      UD.run_target(40, 40)
  def penup():
      UD.run_target(40, -40)
  def nextline():
      LR.run_target(40, 300)
      FB.run_target(40, 30)
  def nextdot():
      LR.run_target(40, -30)
  
  byteval = '''
  0000000000100100001001000000000000100100001111000000000000000000
  '''
  
  bytevalues = list(byteval)
  
  # wait a bit
  time.sleep(5)
  
  # define grid limit
  
  x_limit = 8
  y_limit = 8
  number_of_cells = x_limit * y_limit;
  x = 0
  # scan grid and perform action depending on cell value
  
  while x < (number_of_cells):
      z = bytevalues[x]
      if z == '1': #draw a dot
          pendown()
          penup()
          nextdot()
      elif z == '0': #go to next cell value
          nextdot()
      x+=1
      if (x % x_limit) == 0: #go to next line
          nextline()
  
  [I'm using an 8-Bit happy face as my image]
  I don't know why this weird movement is happening, I don't think it should, please help me with this issue.
  
  **Tags:** ev3, programming, pybricks
  > **Comments:**
  > **username_1**: Have you tried putting a sleep in your while loop ?  
  > **username_0**: I did, still isn't working  
  > **username_0**: Changed more values, now it drew 4 dots in a column? I'm very confused  
  > **username_2**: I think this question should be on Stack Overflow.  
  > **username_0**: It could be, but you need people familiar with EV3 and ev3python.  
  > **username_1**: You accepted my answer (green checkmark), does this mean it fixed your problem?  
  > **username_0**: Yeah, it solved my problem, thanks!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-12-13. Score: 5 | Accepted answer
  
  You are using the function run\_target... which tells the motor to run to a specific angle.
  So it turns to an absolute position...
  
  This might be correct for the pen\_up and pen\_down cases, but I think that for the movement, you want relative movement, i.e. relative from your current position, hence I think the instruction you need is run\_angle instead of run\_target.
  
  
  ---
  
  