Data Comunication - rs232GUI - Signed Number

Create new topics, add your comment, remark, bugs...
Post Reply
Alberto

Data Comunication - rs232GUI - Signed Number

Post by Alberto » Fri Apr 04, 2008 1:29 am

Hi,

I am want to log data that from my encoder using the qei that is
sometimes negative using the TX Output Multiplexed for matlab, but
think it can only be used with signed values. Is it possible to configure the
Tx Output Multiplexed to support negative values or a modification to the block software is
necesary, and how is this achieved?

I would like to know how the data is sent to PC serial port from the dsPic so I can
may be able to interprete the data as signed unisng other matlab tools (external mode for example).

Thanks.
A. Soria.


PS. My qei version for the 30f4012


include <qei.h>
#include <p30f4012.h>
#include <ports.h>

#include "rtwtypes.h"

int ct_turns;


#define TRIS_QEA _TRISB4
#define TRIS_QEB _TRISB5
#define ENTRADA 1
#define SALIDA 0

void QEIInit(void)
{
ct_turns=0;
ADPCFG = 0xFF;
TRIS_QEA=ENTRADA;
TRIS_QEB=ENTRADA;

WriteQEI(0xFFFF);
ConfigIntQEI(QEI_INT_ENABLE & QEI_INT_PRI_3);
OpenQEI(QEI_DIR_SEL_QEB &
QEI_INPUTS_NOSWAP &
QEI_MODE_x4_MATCH,0);
POSCNT = 0;
return;
}

void __attribute__((interrupt,auto_psv)) _QEIInterrupt(void)
{
if(POSCNT==0)
ct_turns++;
if(POSCNT==0xFFFF)
ct_turns--;
_QEIIF=0;
}


int32_T GetQEI(void)
{
return (int32_T)(ct_turns*65535 +POSCNT);

}

LubinKerhuel
Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Bayonne- France
Contact:

Data Comunication - rs232GUI - Signed Number

Post by LubinKerhuel » Fri Apr 04, 2008 10:26 am

Hi Alberto,

Receiving signed data is a problem of interpretation.
The m code that plot data as signed for int16 data type is done.
Just press the "dflt signe" (for default signed) at the top of the rs232gui user interface and this m code will replace current m code in the interface.
rs232GUI_dfltSigned.png
rs232GUI_dfltSigned.png (17.59 KiB) Viewed 4124 times
This code must be adapted if you use int8 or int83 data. Also you have to adapt if you use signed data on one channel and unsigned data another channel

Thanks for providing your version of QEI peripheral code.

Lubin

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 33 guests