Hi all,
I am new to qt, I am trying to make a gui to control my stage(based on stepper motor). it uses udp protocol to send commands. command structure is as:
header =07 ( 2 bytes)
command to move = FL10000 ( to move 1 cm)
termination <CR> = 13
I made a push button and created slot for the same shown below:
void MainWindow::on_move_1cm_clicked()
{
datagram[0] = 0;
datagram[1] = 7;
datagram[2] = 70;
datagram[3] = 76;
datagram[4] = 45;
datagram[5] = 49;
datagram[6] = 48;
datagram[7] = 48;
datagram[8] = 48;
datagram[9] = 48;
datagram[10] = 13;
udpSocket.
writeDatagram(datagram,
QHostAddress("10.10.10.10"),
7775);
void MainWindow::on_move_1cm_clicked()
{
QByteArray datagram;
datagram[0] = 0;
datagram[1] = 7;
datagram[2] = 70;
datagram[3] = 76;
datagram[4] = 45;
datagram[5] = 49;
datagram[6] = 48;
datagram[7] = 48;
datagram[8] = 48;
datagram[9] = 48;
datagram[10] = 13;
QUdpSocket udpSocket;
udpSocket.writeDatagram(datagram, QHostAddress("10.10.10.10"),7775);
To copy to clipboard, switch view to plain text mode
The problem I am facing is on clicking the button at the first time the stage move, but doesnot when I click it again.
to make this code work again i have to power off my motor.
can anyone tell me what can be wrong.
I am planning on having 3-4 push buttons for different length of move.
Please help me out.
thanks.
Bookmarks