UDCON = UDCON & 0xFE;
The above compiles without error for an Arduino Leonardo. I'll try it in the
shop tomorrow.
Thanks!


-----Original Message-----
From: John Dammeyer <jo...@autoartisans.com> 
Sent: December 4, 2020 7:02 PM
To: 'Enhanced Machine Controller (EMC)' <emc-users@lists.sourceforge.net>
Subject: Re: [Emc-users] USB - Serial question

I don't have an Arduino here that has the ATmega16U4 so I can't try this.
Perhaps someone else can?

Page 281 of the linked data sheet shows UDCON bit 0 holds the Detach Bit.
Googling access to Arduino registers implies that you can just use the data
sheet name to get to the register.

So theoretically this statement in the init() function should disable the
USB.  Ie. It will disappear or won't show up.  
UDCON = UDCON & 0xFE;

Now in the main line monitor one of the port pins that you have connected to
a button and set up as an input.  

If the USB device doesn't show up then you know the DETACH bit has worked.  

When the mainline loop blinking the LED sees the button press execute this:
UDCON = UDCON | 0x01;

Now check the PC to see if the USB port shows up.

If that works then you have an easy way to logically remove the USB
connection.  Initialize all hardware.  Then logically plug the USB cable
back in.

John Dammeyer

> -----Original Message-----
> From: John Dammeyer [mailto:jo...@autoartisans.com]
> Sent: December-04-20 10:22 AM
> To: 'Enhanced Machine Controller (EMC)'
> Subject: Re: [Emc-users] USB - Serial question
> 
> Still requires an output. Whether it's DTR, Power, a Relay or the #RESET
signal.
> 
> Page 272 and 273 talks about the DETACH bit.
> https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7766-8-bit-AVR-
> ATmega16U4-32U4_Datasheet.pdf
> 
> It's worth a try in that blink application working with that bit to see if
Path Pilot no longer sees the serial port once the detach is set.
> And then re-enumerated if cleared 120 seconds later.
> 
> John Dammeyer
> 
> > -----Original Message-----
> > From: Martin Dobbins [mailto:tu...@hotmail.com]
> > Sent: December-04-20 10:02 AM
> > To: Enhanced Machine Controller (EMC)
> > Subject: Re: [Emc-users] USB - Serial question
> >
> > Hi Ken,
> >
> > PJRC's version of Arduino is somewhat different, I wonder if DTR is 
> > what you need?  If you can read the serial.dtr as shown here, then I'm
pretty sure you can hold DTR low until you are ready to send/receive data:
> >
> > https://www.pjrc.com/teensy/td_serial.html
> >
> > Martin
> >
> > ________________________________
> >
> >
> > Your suggestion sounded great so I did a few tests. I loaded a PCJR 
> > Teensy LC (ARM Cortex-M0+) and a genuine Arduinio Leonardo 
> > (ATmega32u4) with the standard BLINK program --  <much snippage>
> >
> > > Emc-users mailing list
> > > Emc-users@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/emc-users
> > >
> > >
> > >
> > > _______________________________________________
> > > Emc-users mailing list
> > > Emc-users@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/emc-users
> > >
> >
> >
> > --
> >
> > -users mailing list
> > Emc-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/emc-users
> >
> >
> >
> > _______________________________________________
> > Emc-users mailing list
> > Emc-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/emc-users
> >
> > _______________________________________________
> > Emc-users mailing list
> > Emc-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/emc-users
> 
> 
> 
> _______________________________________________
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users



_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users



_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to