Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 20:55 18 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Backpack144 Extreme Newbie Help

     Page 2 of 3    
Author Message
retepsnikrep

Senior Member

Joined: 31/12/2007
Location: United Kingdom
Posts: 131
Posted: 10:56pm 03 Apr 2017
Copy link to clipboard 
Print this post

Thanks to WW (Phil) for talking me through basically what Big Mik has also posted.
Those OPTIONS and some tweaks to the TeraTerm setup got it going.

It's now up and running via a serial dongle attached to the console pins.
I have added the 0.1uf cap to the crystal to eliminate the reset key press requirement.

The 16F chip appears dead as my pic programmer won't detect it.
So that probably explains why the XP driver won't load..
I'll get another and try that again.

I'll shut the window for now as it might not need to be thrown out of it just yet..
Gen1 Honda Insights.
 
retepsnikrep

Senior Member

Joined: 31/12/2007
Location: United Kingdom
Posts: 131
Posted: 04:48am 17 Apr 2017
Copy link to clipboard 
Print this post

Finally solved the onboard interface driver install failure issue.

The 16LF1454 chip was not blown. Sorry WW..

I looked again at recommended MCP2200 driver inf file and it was trying to copy/reference the usbser.sys file, but it did not exist on my system and did not tell you, just failed to install with the inf invalid message.

I downloaded a copy and put it in the windows/system32/drivers file and the install completed correctly.. Flags are out here now and there is rejoicing in the street...

Now talking to the extreme as intended and not via console connection..
Gen1 Honda Insights.
 
retepsnikrep

Senior Member

Joined: 31/12/2007
Location: United Kingdom
Posts: 131
Posted: 08:50pm 23 Apr 2017
Copy link to clipboard 
Print this post

Trying to send some serial data now on Com1 but can't find the syntax for the print # command. Yes I have seen the entry in the manual but it doesn't really help.
I can't see any reference to how to send hex numbers.
I want to send a sequence of bytes say $AA $BB $FF etc etc

I tried PRINT #1,$AA;$BB;$CC; it doesn't like that like that..

The port is open.Edited by retepsnikrep 2017-04-25
Gen1 Honda Insights.
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2794
Posted: 08:54pm 23 Apr 2017
Copy link to clipboard 
Print this post

Hi Peter,

One way is to send the bytes as individual characters with CHR$. So something like:

PRINT #1,CHR$(xx);CHR$(yy);CHR$(zz);

You may need to change the ';' character in the above (and/or remove from end) as depends if you need CR LF characters sent too.

WW


For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2794
Posted: 08:57pm 23 Apr 2017
Copy link to clipboard 
Print this post

For sending HEX use: CHR$(&HAA)
For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 08:58pm 23 Apr 2017
Copy link to clipboard 
Print this post

Try
PRINT #1,CHR$(&hAA);CHR$(&hBB);CHR$(&hCC);

You can also use the decimal values instead of HEX.

Every thing is sent as a string of characters so it's either CHR$() or string variables or "quotes"

Jim
VK7JH
MMedit   MMBasic Help
 
retepsnikrep

Senior Member

Joined: 31/12/2007
Location: United Kingdom
Posts: 131
Posted: 09:09pm 24 Apr 2017
Copy link to clipboard 
Print this post

OK Thanks values now being sent OK.

However I have initialized Com2 as a serial port at 10400 baud. No problem.

But i need to send some very slow pre-amble first to wake up the receiver.
I noted Com2 Tx is on pin 127 on the extreme. So i did.

Setpin(127),Dout
pin(127) = 1 'Set K line Com2 TX high (1)
pause 200 'Pause 200ms
pin(127) = 0 'Set K line Com2 TX low (0)
Pause 70 'Pause 70ms
pin(127) = 1 'Set K line Com2 TX high (1)
pause 145 'Pause 145ms
open "COM2:10400" AS #2 'open the second serial port with a speed of 10400 baud KLine


When i tried that the com port failed with pin already in use :(
Hmm how to send my pre-amble.. Can i release the pin so that the com port then works?Edited by retepsnikrep 2017-04-26
Gen1 Honda Insights.
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2794
Posted: 09:24pm 24 Apr 2017
Copy link to clipboard 
Print this post

add a line SETPIN(127),OFF immediately before OPEN . . .

WW
For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
retepsnikrep

Senior Member

Joined: 31/12/2007
Location: United Kingdom
Posts: 131
Posted: 10:09am 25 Apr 2017
Copy link to clipboard 
Print this post

Thanks for the help.

Now a little coms problem.

I'm transmitting data no problem from COM1 & 2 TX pins however the RX pins seem to being held high (perhaps via pullups inside the pic) is this normal behaviour.

I would have expected them to be high impedance input so they would shift up or down easily especially when using a 10k series resistor and diode to +3.3V to protect them.

I measured the bare RX pins and they def appear to be being pulled up or held high.
This creates a potential divider with the 10k series resistor and the internal pull up making it harder for the external serial signal to drive them low.. Or am I missing something.. I'm reluctant to reduce/remove my series resistor to force them low/er..

Gen1 Honda Insights.
 
retepsnikrep

Senior Member

Joined: 31/12/2007
Location: United Kingdom
Posts: 131
Posted: 08:42pm 25 Apr 2017
Copy link to clipboard 
Print this post

loopback mode with Com1 Tx connected to Com2 RX via a 1k resistor seems to work ok and vice versa Com2 TX toCom 1 Rx.

But the rx lines (when disconnected) are still held high presumably by a pullup in the pic.

Is that what was intended?

The low impedance 1k resistor can overcome the presumably 100k pullup?Edited by retepsnikrep 2017-04-27
Gen1 Honda Insights.
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1995
Posted: 09:10pm 25 Apr 2017
Copy link to clipboard 
Print this post

Hi Peter.

The RX pins can't be in a genuinely high-impedance state (i.e. effectively disconnected) when inactive because they have to be ready to see the Start bit of any transmission.

It may be that they "drift" Hi (and MOS has a natural high impedance on inputs) and pulling them up internally is quite common - as you suspected. They will almost certainly be driven Hi by the corresponding Tx pin.

The start and stop bits on RS232 style comms pins are at different levels - the start bit is Lo, the stop bit is Hi. Thus when communications are over for a while, the Tx pin sits Hi indefinitely. When it is about to start a new round of comms, the Tx pin goes Lo for the duration of one bit - this is seen by the Rx pin which then knows new data is about to arrive. Typically the receiving equipment then waits for 1.5 bits and samples the next X data bits at the baud rate (so right in what should be the middle of each bit) and then once more to confirm the stop bit. This is why if the data rate is wrong, you tend to get garbage instead of the packet rejected because it has no real way to tell if the data is good or not for the baud rate. Usually there is a bit more work done than this but simply that is enough and I have bit-bashed RS232 on traditional CPUs using precisely this method reliably.

Interesting historical detail: "proper" RS232 used levels of +15 and -15v (or some variation) with the data bits sort of inverted from what you might expect(Lo=+15 Hi=-15) but with a high degree of tolerance on these levels because you might be driving into several hundred meteres of cable (I used RS232 down almost a Kilometer, cross-site, from RADAR installations as an apprentice with EMI decades ago and it worked without a hiccup). Because the RX pin was left sitting at -15v (logically a 1 - the stop bit[s]) you could "steal" -15v from the other end via a diode pump to a capacitor to use in peripheral equipment that had no negative supply. That way you could give good levels on something that only had +5v available. It was a tough protocol that allows some very dodgy practices to work reliably

h
Edited by CaptainBoing 2017-04-27
 
retepsnikrep

Senior Member

Joined: 31/12/2007
Location: United Kingdom
Posts: 131
Posted: 09:20pm 25 Apr 2017
Copy link to clipboard 
Print this post

There is an option for the digital pin associated with the COM RX input to be high impedance.

DIN with 'option' omitted.

I tried setting the Com1 & 2 RX pins to DIN + no pull up/down.

But of course i expect as soon as you designate them as com ports and open it they connect the pull ups.. I'm stuck now..

I tested the RX pin with SETPIN DIN and it does go high impedance with no pull up.
But as soon as you designate it as a com port the internal pullup is activated killing my serial comms.

Is this a basic internal issue?

I presume i will have to reduce my pin protection series resistor. At the moment with a 10k resistor the RX pin just cannot be pulled down low enough to register a logic 0. :(
Edited by retepsnikrep 2017-04-27
Gen1 Honda Insights.
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1995
Posted: 09:30pm 25 Apr 2017
Copy link to clipboard 
Print this post

there are basic functions to manufacture additional comms ports by bit-bashing "normal" IO pins.

I have never done this but you might like to try using that with a bog-standard IO pin instead of the dedicated COM pins - it may get around the lack of control when using the built in comms ports.

Inside the Micromite Firmware ZIP, there is a folder called Embedded C Modules. and in there you'll find two PDFs detailing software versions of the com ports that will work on any IO pin - I have attached them here

If this works without redefining the pins purely to comply with comms protocols, that might allow you to manipulate the Rx/Tx pins behind its back

2017-04-26_072933_Serial.zip

Edited by CaptainBoing 2017-04-27
 
retepsnikrep

Senior Member

Joined: 31/12/2007
Location: United Kingdom
Posts: 131
Posted: 09:35pm 25 Apr 2017
Copy link to clipboard 
Print this post

With 5v TTL coms I dropped by series resistors to 4.7k still not enough to go low against the internal RX pin voltage..

The internal pullup resistors ASFAIK are not exact values so this seems a bit hit and miss..
Gen1 Honda Insights.
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1995
Posted: 09:39pm 25 Apr 2017
Copy link to clipboard 
Print this post

just realised - you might need to check compatibility of those functions with the MMX. They are originally for the MX based micromites.

give it a try - you can't break anything
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1995
Posted: 09:40pm 25 Apr 2017
Copy link to clipboard 
Print this post

  retepsnikrep said   With 5v TTL coms I dropped by series resistors to 4.7k still not enough to go low against the internal RX pin voltage..

The internal pullup resistors ASFAIK are not exact values so this seems a bit hit and miss..


try using that code I attached - it uses any old IO pin and if you get off the deicated comms ports you might not have the same problem
 
retepsnikrep

Senior Member

Joined: 31/12/2007
Location: United Kingdom
Posts: 131
Posted: 09:54pm 25 Apr 2017
Copy link to clipboard 
Print this post

Thanks, but unfortunately that does not work in the background which is what I need.

The COM1 & 2 RX pin measures 3.247V when initialised and unconnected.

A 10k resistor to ground reduces that to ~2.029V, indicating that the internal pull up is around 6k or the pin is actively being driven high.

The result is the same for both RX pins.. Surely this is not intended..

This is the code I am running just for this test.

OPTION EXPLICIT 'we want to ensure variables are declared explicitly

OPEN "COM1:9600" AS #1 'open the first serial port with a speed of 9600 baud HLine
open "COM2:10400" AS #2 'open the second serial port with a speed of 10400 baud KLine

DO 'start the do loop that runs forever
LOOP


If you can't drive the RX pin low the comms is never going to work..

The TX-RX loop back with the 1k resistor could overcome the 6k equivalent pull up and generate a logic low.

Perhaps this is a hardware/pic or basic issue.

I have used pics extensively in the past for USART and serial port work and have never encountered the RX pin being driven/pulled high like this internally.Edited by retepsnikrep 2017-04-27
Gen1 Honda Insights.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 10:26pm 25 Apr 2017
Copy link to clipboard 
Print this post

There was a history of problems with the Rx pins being left floating. The pullup was turned on to prevent the garbage being generated. This saved users having to remember to include an external pullup.

If you are connecting to a 5V device and the Com port is only 3.3V tolerant, a 1k resistor has been found to be reliable with either 5V or 3.3V connections.
On all my boards I include the 1k resistor so I don't have to worry about the connecting device.
Some of the 'mites have 5V tolerant com port pins.

If you are connecting to a true RS232 which swings negative, a 10k resistor is a good choice.

If I don't trust the external devices or with long leads, I use a MAX232 as a sacrificial interface.

Jim
VK7JH
MMedit   MMBasic Help
 
retepsnikrep

Senior Member

Joined: 31/12/2007
Location: United Kingdom
Posts: 131
Posted: 10:52pm 25 Apr 2017
Copy link to clipboard 
Print this post

I think we need an 'option' to turn this pullup off please if possible.
I'm using two comms lines one 5v ttl and one 12V ttl (no negative)

The 1k series resistor still struggles to pull the line down to logic zero level with the RX pull up to 3.3v active.. :(

With the 12v line I have used a potential divider 18k/10k in the past to reduce the voltage to the com port RX input range 5v or 3.3v. That has worked fine for years. However this internal RX pin pull up means I can't do that. :(

I'm not sure if Com1 RX (69) and Com 2 RX (128) on the MMX 144 are 5v tolerant..

Open to other ideas on fixing the issue.. Thanks so far for thoughts.

Edited by retepsnikrep 2017-04-27
Gen1 Honda Insights.
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2294
Posted: 03:01am 26 Apr 2017
Copy link to clipboard 
Print this post

if you truely need a high-impedance input, then add a buffer (or an op-amp configured as a buffer) in front of the pin. if a serial RxD pin were configured as high-impedance without any pullup, it is possible that serial data on some other pin of the pic32 could produce 'ghost' data on that high-impedance input.

the explore-28 boards use 1k5 resistors in series with both RxD and TxD. with a 3v3 supply this limits current to 2mA, well within the 20mA that the pic32 pins are ok with.


cheers,
rob :-)
 
     Page 2 of 3    
Print this page
© JAQ Software 2024