×

INDI Library v2.0.7 is Released (01 Apr 2024)

Bi-monthly release with minor bug fixes and improvements

Update port or baud rate

  • Posts: 281
  • Thank you received: 29

Replied by Helge on topic Update port or baud rate

Hi Paul, I was just trying to figure out what is happening, so I added a few lines to the code at line 75 I squeezed in the following:

IDMessage(getDeviceName(), "Command 0 %d", command[0]);
IDMessage(getDeviceName(), "Command 1 %d", command[1]);
IDMessage(getDeviceName(), "Command 2 %d", command[2]);
IDMessage(getDeviceName(), "Command 3 %d", command[3]);
IDMessage(getDeviceName(), "Command 4 %d", command[4]);
IDMessage(getDeviceName(), "Command 5 %d", command[5]);

The log file is interesting and seems to confirm your doubts, see attached log file from time stamp 2019-02-10T20:52:15.932 onwards (to the end of the file). I first set steps to 100, then back to zero, then 400 and back to zero. The command[] should in hexa decimal be 0xE0, according to the User Guide (www.pololu.com/docs/0J71/9). But in the log I see -32. Maybe this is the char value of "0", as the term 0xE0 starts with 0 (???).

But how to resolve, as the tty_write command requires a char variable?
5 years 2 months ago #34871
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 281
  • Thank you received: 29

Replied by Helge on topic Update port or baud rate

Sorry, just realized I have been fooling myself with %d for showing the content of the char command variable.

I am giving in for today! :-)
Last edit: 5 years 2 months ago by Helge.
5 years 2 months ago #34873

Please Log in or Create an account to join the conversation.

  • Posts: 220
  • Thank you received: 27

Replied by PDB on topic Update port or baud rate

I am reading the polulu guide, trying to understand what exactly needs to be sent. Will see if I can find a solution.

P
5 years 2 months ago #34892

Please Log in or Create an account to join the conversation.

  • Posts: 220
  • Thank you received: 27

Replied by PDB on topic Update port or baud rate

Try this, it compiles and sends data but can't check the result.

change command back to

uint8_t command[6]

change write to :

if ( (rc = tty_write(PortFD, (char *) command, sizeof(command), &nbytes_written)) != TTY_OK)
{
tty_error_msg(rc, errstr, MAXRBUF);
DEBUGF(INDI::Logger::DBG_ERROR, "Init error: %s.", errstr);
}


Dont't forget to correct alst exit_safe_start (That was currently sending no data (i forgot to set the data byte) maybe that caused your problems.

uint8_t command[] = { 0x83 };
(and cast in tty_write)

I think INDI sets the terminal raw as needed to send this binary data. So hopefully that works. Binary data on a ttyport can be interrpreted as contol chars if not all tyy settings are correct.

Looking at the doc it seems you can read the motor position from the device, so you could read that periodically (Timerhit) and wait until correct position is reached before accepting new commands. (Some programming needed, but should be possible)

Looks like an interesting motor controller, maye I should buy one for myself.

Regards,

Paul
5 years 2 months ago #34893

Please Log in or Create an account to join the conversation.

  • Posts: 220
  • Thank you received: 27

Replied by PDB on topic Update port or baud rate

I ordered one. Should arive tomorrow.

Paul
5 years 2 months ago #34895

Please Log in or Create an account to join the conversation.

  • Posts: 281
  • Thank you received: 29

Replied by Helge on topic Update port or baud rate

Dear Paul, it is working now! I am really impressed, thank you very much once again for your support.

First, it did not work, then checked via the ticgui the status, and the motor needed to be re-energized (there is a button at the bottom of the GUI).

I uploaded the file in its latest version.

Best, Helge
5 years 2 months ago #34919
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 281
  • Thank you received: 29

Replied by Helge on topic Update port or baud rate

One more thing - tried different things to save the configuration for the port, in my case rfcomm1. Attchached the .cpp and .h file - but that did not work.

I hardly dare to ask again Paul - but in case weather conditions are again unfavorable, could you have a look? :-)
5 years 2 months ago #34949
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 220
  • Thank you received: 27

Replied by PDB on topic Update port or baud rate

Must be a conflict between the built-in save-routine and your declarations. (Did you use the "save" button in the options panel?

So if you want to save your extra items, try this:

in the .h file change:
virtual bool saveConfigItems(FILE *fp);
to
virtual bool saveConfigItems(FILE * fp) override;

in the c++ code add just before line 320:

INDI::Focuser::saveConfigItems(fp);

Rgrds,

Paul
The following user(s) said Thank You: Helge
5 years 2 months ago #34961

Please Log in or Create an account to join the conversation.

  • Posts: 281
  • Thank you received: 29

Replied by Helge on topic Update port or baud rate

Hi Paul, it works, I am really pleased - thank you once again!!

Attached just a picture of the TIC825 with the HC-05 module.
Last edit: 5 years 2 months ago by Helge.
5 years 2 months ago #34979
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 220
  • Thank you received: 27

Replied by PDB on topic Update port or baud rate

That looks very good. (got my tic yesterday and now trying to make a driver that talks directly to the tic over the usb port. Still have to decide if I go for that or put an arduino nano in between and make a moonlite compatible protocol) If I do direct USB the board is soo small it can be fixed to the motor (so no risc of blowing the 8825 driver when connecting/disconnecting the motor when the board is powered)

Paul
5 years 2 months ago #34982

Please Log in or Create an account to join the conversation.

  • Posts: 281
  • Thank you received: 29

Replied by Helge on topic Update port or baud rate

Hi, in principle, the focuser works as it is supposed to, but upon connection, I am having difficulties to get the stepper going (in the Ticgui I am getting an error message, which says that the stepper has been de-energized because of a “safe start violation error“. Once clicking on the resume button, it is all working.

I started to compare the code example on the Pololu website, to compare it to my driver. Thanks to the incredible support of Paul, I am now leveraging on the INDI API. Practically, there is a function called „handshake“, which I assumes opens up the serial port. Unfortunately, I do not find anything in the documentation what is exactly happening code-wise, for instance is something like this implemented, or any options set, or is there e.g. a tcflush command applied?
fd = open(device, O_RDWR | O_NOCTTY);

Many thanks in advance for any support!

Helge
5 years 1 month ago #35846

Please Log in or Create an account to join the conversation.

  • Posts: 220
  • Thank you received: 27

Replied by PDB on topic Update port or baud rate

Hi,

the handshake function will not be usefull here. It is used to decide if you are talking to the correct device. (send command, get response and check, return true if ok)

What you need to do is energize the motor. (www.pololu.com/docs/0J71/8#cmd-energize)
This is a quick command and only requiers one byte to send (command code)

Had the same problems in my implementation, and solved it by doing this. (But since I talk directly to the USB i use the API commands, not the serial commands)

After that you will need to think about the position of focuser and steppermotor. If you don't take power of the motor stepper position will be were you left it. When power/off power/on it will probably be 0 (also seen negative values) so I am still thinking about a sort of calibration routine. (probably with a limit switch and homing mode to calibrate at absolute 0) ....

Now I am struggling to make an ASCOM driver :-( How much I like Indi, can't live without Win for fast usb connection. And my main area is solar astrophotography were I need the fastest USB camera rate I can get. (And Linux, or the drivers could not coop with that. )

This is my current Connect, you will need to translate Tic commands to their serial equivalent

bool TicFocusUsb::Connect()
{
DEBUGF(INDI::Logger::DBG_SESSION, "TiFocus searching for :%s:", desired_serial_number);
std::vector<tic::device> list = tic::list_connected_devices();
// Iterate through the list and select one device.
for (const tic::device & device : list)
{
DEBUGF(INDI::Logger::DBG_SESSION, "TicFocus has got:%s:", device.get_serial_number().c_str());
if (strcmp(desired_serial_number, "Any") &&
(strcmp(desired_serial_number, device.get_serial_number().c_str())))

// Found a device with the wrong serial number, so continue on to
// the next device in the list.
continue;
ticDev = tic::handle(device);
tic::variables vars = ticDev.get_variables();

currentPosition = vars.get_current_position();

if (currentPosition < 0) ticDev.halt_and_set_position(0);
curStepMode =vars.get_step_mode();
ticDev.set_max_speed(500000000);


ticDev.energize();
SetTimer(POLLMS);
ticDev.go_home(0);
return true;
}
DEBUG(INDI::Logger::DBG_SESSION, "No device found");
return IPS_IDLE;
}


Regards,

Paul
5 years 1 month ago #35852

Please Log in or Create an account to join the conversation.

Time to create page: 0.756 seconds