Announcement

Collapse
No announcement yet.

Need help sending Knob data to my microcontroller using serial.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need help sending Knob data to my microcontroller using serial.

    With the turn of the knob widget I would like to send the knob value using serial COM1 to my microcontroller. So far I tried:

    func movef1knob()
    var degrees;

    // knob1 generated 11/11/2011 2:51:42 PM
    degrees := XYposToDegree(x-322, // x - CentreX
    y-50) ; // y - centreY
    if (degrees < 45) // anything in the first 'dead zone' is minvalue
    degrees := 0 ;
    else
    if (degrees > 315) // anything in the last 'dead zone' is maxvalue
    degrees := 270 ;
    else
    degrees -= 45 ; // offset by -baseangle
    endif
    endif
    posit1 := degrees * 100 / 270 ; // convert degrees to position
    img_SetWord(hndl, iKnob1, IMAGE_INDEX, posit1);
    img_Show(hndl, iKnob1);

    txt_MoveCursor(9,38);
    print([DEC3ZB] posit1) ;
    to(COM1); putstr(posit1);
    endfunc

    putstr(posit1); does not seem to send the value to my microcontroller. To test if my microcontroller is properly setup to receive serial data I placed serout1('a'); in the repeat forever section of the code. My microcontroller outputs "Data Received" and repeats. I removed the serout1('a') once I knew my microcontroller was able to receive data.

  • #2
    I have no idea why you would use putstr (Put String) on a number, it will only work for strings.

    Use either
    to(COM1) ;
    print([DEC3ZB] posit1) ;
    if you want an ASCII number written to the com port, or
    serout(posit1 >> 8) ;
    serout(posit1) ;
    if you want the number written as binary.
    Mark

    Comment


    • #3
      Originally posted by ESPsupport View Post
      I have no idea why you would use putstr (Put String) on a number, it will only work for strings.

      Use either
      to(COM1) ;
      print([DEC3ZB] posit1) ;
      if you want an ASCII number written to the com port, or
      serout(posit1 >> 8) ;
      serout(posit1) ;
      if you want the number written as binary.
      Thank you for taking the time to help. I do realize putstr work with strings. I didn't realize that it will only work for strings. I was able to get serial communication to work between the display and the microcontroller. Thanks again for your help.

      Comment

      Working...
      X