kevinferrare / arduino-st4

A PC-Telescope interface built around an arduino
90 stars 25 forks source link

Implementation on a standalone ATmega328 uP #14

Open nevilyoung opened 1 year ago

nevilyoung commented 1 year ago

Hi Kevin or anybody - Perhaps I am trying to be too clever because I decided to use an ATmega328 chip on its own for space saving reasons. I can get the autoguider code to work if I go through the standard Arduino microcontroller board, but not through the standalone chip, with which I communicate through a FT232 USB to serial adapter. That works fine for communicating with and successfully programming the uP (eg Blink), but I cannot communicate with the autoguider that has been loaded onto the chip. I suspect that the Autoguider driver cannot see the auotoguider through the FT232 driver. I have tried various combinations of COM ports. Am I doing something silly here? Would there be conflicts between drivers and ports? 20220918_151240

SteveBz commented 1 year ago

If it works from the pc via the usb and ft232 with blink on the 328, it'll work with anything. It's probably something silly, like a line terminator or baud rate or something.

nevilyoung commented 1 year ago

OK - so it should work. Baud rates double checked. The autoguider code is as written by Kevin and works fine when run on the microcontroller board. I have put the question to the Arduino forum, so if I find a solution, I will post it here. Thanks.

nevilyoung commented 1 year ago

Another possibility - Arduino IDE can see the ATmega328 chip through the FT232. Perhaps there is something in the Arduino driver that makes that happen. Perhaps whatever the 'something' is in the Arduino driver is not in Kevin's autoguider driver. Of course he was not considering that the autoguider would be used on a standalone ATmega328 - if that makes a difference.
BTW - I registered on the Arduino forum 24 hrs ago but am 'on hold' while I am being vetted. Can't wait to post my question there.

nevilyoung commented 1 year ago

Finally found an answer at Arduino forum. In case someone else runs into this problem, here is the long story. Jump to the end to see the solution.

NOTE: I eventually found a solution to this problem (see below), but here is the scenario: My implementation for a telescope autoguider uses a standalone Atmega328. I communicate with it via an FT232 USB-Serial converter board. I can download Kevin's Arduino Autoguider program to the chip. I can download Blink to the standalone 328 - it works just fine.

I am using an an autoguiding program called PHD2. PHD2 cannot communicate with the Arduino Autoguider because the computer only sees the FT232 board.

If I instead programmed the Arduino Autoguider program into an UNO board, (which means that I am now using the UNO’s onboard USB-Serial converter), the Arduino Autoguider program works just fine. The is no apparent clash between the autoguider and the FT232 drivers.

My question was: Should it be possible to communicate with the autoguider on the standalone Atmega328 via the FT232? While I was writing up this post on the forum, I was prompted to look at this post “Standalone ATMEGA328 with CP2102 USB-Serial Converter”, which had not cropped up in my previous searches.

@iceeyes1992 – had the exact solution. “i had the same problem.i had a atmega328p and a cp2102 with dtr pin.i tried different ways.after spend of 3 days i found the solution. after burn bootloader to raw atmega328p with arduino as isp or usbasp you must choose only arduino pro or pro mini as your board in tools menu and one of the avr isp or arduino as isp or avr isp mkll as programmer.and then upload your sketch.that’s it.”

NOTE: I had burned a bootloader onto the Atmega328 earlier via the UNO board. And then had uploaded the Arduino Autoguider sketch, probably with Board: Arduino UNO selected – I think. Uploading worked fine, but PHD2 did not see the autoguider. The COM port was 4 and called something like “Serial Converter” when I was expecting to see “ArduinoST4 telescope driver (ASCOM)”.

So – following the advice from @iceeyes – I reconnected to the standalone ATmega through the FTP232 converter. I simply selected Board: “Arduino Pro or Pro Mini”. An extra field opens up – Processor, from where I selected the “Atmega328P (5V, 16Mhz)”. I then uploaded the AutoguiderST4 program again.

The PHD2 guiding program then saw the “ArduinoST4 telescope driver (ASCOM)” in the Mount selection list in PHD2. Success! Guiding is working fine.

(Note: PHD2 will not connect to the autoguider after the Arduino IDE has been connected to the 328. Messages received were COM4 denied or other times response too slow. I had to unplug the autoguider, then plug it in again. )

Bottom line – for standalone Atmega through USB-Serial converter, Select Arduino pro or pro mini as your board. PS: I might be mistaken about some of the sequences, but became very confused while sorting out the problem over several days. Hope this is useful.

Thank you Kevin! 20221001_084046