Cheap web-modem for the beeb/master (and arc if ya like!)

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
stevebubs
Posts: 19
Joined: Thu Mar 09, 2017 1:01 am
Location: Berks
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by stevebubs » Wed May 16, 2018 8:38 am

Daniel,

5v Plug in boards forz the ESP8266 exist for pennies...

https://rover.ebay.com/rover/0/0/0?mpre ... 2959763723

User avatar
hoglet
Posts: 7523
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by hoglet » Wed May 16, 2018 8:57 am

Daniel,

In the technical reference for the EPS8266 there is some information on enabling RTS/CTS flow control in 11.3.10:
https://www.espressif.com/sites/default ... df#page=89

The functions referred to, e.g. UART_SetFlowControl, appear to be part of the ESP8266 SDK:
https://github.com/espressif/ESP8266_IO ... art.c#L229

Dave

User avatar
danielj
Posts: 6597
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by danielj » Wed May 16, 2018 8:58 am

So as far as I can tell, those won't take it to the +5V and -5V levels needed for RS423, and certainly won't take it to the levels needed for RS232 (+/-10V). You need a MAX3232 to do that. Those boards just convert the 3.3V to 5V for arduino.

So, that whole set up is just designed to plug into an arduino which you'll then need to use to program it, whereas the NODE-mcu board enables direct programming of the ESP8266 microcontroller (actually an ESP-12E module on the nodemcu). £2.50 + price of arduino is still going to be more than the fiver for the node-mcu. And you'd still have to buy the RS232 level shifter on top of that.

d.

User avatar
danielj
Posts: 6597
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by danielj » Wed May 16, 2018 9:03 am

hoglet wrote:Daniel,

In the technical reference for the EPS8266 there is some information on enabling RTS/CTS flow control in 11.3.10:
https://www.espressif.com/sites/default ... df#page=89

The functions referred to, e.g. UART_SetFlowControl, appear to be part of the ESP8266 SDK:
https://github.com/espressif/ESP8266_IO ... art.c#L229

Dave
Thanks Dave, I did see that - the problem is I'm using the arduino ESP8266 SDK, which is ultimately easier to work with for your average Joe (i.e. me :D), and it doesn't provide the flow control functions. What I can't quite divine (and I haven't had time to test) is whether this is genuinely hardware and if I set the registers appropriately will just "work", or whether it sets a few hardware behaviours in train (involving interrupts and the like) that the software then has to deal with. I'm going to attempt to give it a bit of an exercise over the weekend when I get a moment :)


d.

User avatar
hoglet
Posts: 7523
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by hoglet » Wed May 16, 2018 9:33 am

danielj wrote: What I can't quite divine (and I haven't had time to test) is whether this is genuinely hardware and if I set the registers appropriately will just "work", or whether it sets a few hardware behaviours in train (involving interrupts and the like) that the software then has to deal with. I'm going to attempt to give it a bit of an exercise over the weekend when I get a moment :)
I would expect it would all be done in hardware, especially as a threshold is programmed.

The code is basically:

Code: Select all

UART_SetFlowCtrl(UART_Port uart_no, UART_HwFlowCtrl flow_ctrl, uint8 rx_thresh)
{
    if (flow_ctrl & USART_HardwareFlowControl_RTS) {
        PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_U0RTS);
        SET_PERI_REG_BITS(UART_CONF1(uart_no), UART_RX_FLOW_THRHD, rx_thresh, UART_RX_FLOW_THRHD_S);
        SET_PERI_REG_MASK(UART_CONF1(uart_no), UART_RX_FLOW_EN);
    } else {
        CLEAR_PERI_REG_MASK(UART_CONF1(uart_no), UART_RX_FLOW_EN);
    }

    if (flow_ctrl & USART_HardwareFlowControl_CTS) {
        PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_UART0_CTS);
        SET_PERI_REG_MASK(UART_CONF0(uart_no), UART_TX_FLOW_EN);
    } else {
        CLEAR_PERI_REG_MASK(UART_CONF0(uart_no), UART_TX_FLOW_EN);
    }
}
All these things will just be macros, and just need to be translated to the equivalents in the arduino ESP8266 SDK (or indeed just to raw C pointer thingies). Let me have a quick try at this....

Dave

User avatar
hoglet
Posts: 7523
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by hoglet » Wed May 16, 2018 10:29 am

hoglet wrote:All these things will just be macros, and just need to be translated to the equivalents in the arduino ESP8266 SDK (or indeed just to raw C pointer thingies). Let me have a quick try at this....
Dave
Well, this at least compiles!
https://github.com/hoglet67/esp8266_mod ... b4c189261a

User avatar
danielj
Posts: 6597
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by danielj » Wed May 16, 2018 10:47 am

That's a good start! :D *holds breath* =D>

:)

(just to note, there's a 1ms delay I stuck in to stop it crashing out with a software exception when background processes aren't serviced frequently enough, I intend take that out and create other opportunities to yield to background processes in the main loop)

d.

Andy1979
Posts: 110
Joined: Mon Mar 27, 2017 9:04 pm
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by Andy1979 » Wed May 16, 2018 1:58 pm

danielj wrote:Yes they are domino, I got them from cpc :)
UPURS is much faster :)

d.
They seem to be out of stock at CPC, but do have the 'locking' version. Any idea if that will fit, or does the locking mechanism get in the way?

http://cpc.farnell.com/deltron-enclosur ... dp/CN00046

My Compact has dual floppies, so have been tempted to swap one of them out with a Gotek. The appeal of MMC is being able to ditch the base unit though. Also not sure if the Gotek has mounting holes in the bottom like the Compact's floppy drives, although I'm sure a solution that that issue can be easily engineered, and it would save me from needing to get MMFS burned to an EPROM.

User avatar
danielj
Posts: 6597
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by danielj » Wed May 16, 2018 2:12 pm

Andy1979 wrote: They seem to be out of stock at CPC, but do have the 'locking' version. Any idea if that will fit, or does the locking mechanism get in the way?

http://cpc.farnell.com/deltron-enclosur ... dp/CN00046
Couldn't guarantee it, but it looks like the locking bit is optional, so it may well do? Otherwise they'll have the others back in stock around the 11th June by the looks of things. There must be other places that sell them though.
My Compact has dual floppies, so have been tempted to swap one of them out with a Gotek. The appeal of MMC is being able to ditch the base unit though. Also not sure if the Gotek has mounting holes in the bottom like the Compact's floppy drives, although I'm sure a solution that that issue can be easily engineered, and it would save me from needing to get MMFS burned to an EPROM.
I think the compact drives are a little taller than the goteks, but the goteks do have mounting holes on the bottom. The other option is just to build the relevant cable to plug them into the back of the compact directly without using the base unit?

d.

User avatar
danielj
Posts: 6597
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by danielj » Wed May 16, 2018 6:11 pm

So, that HW-flow register twiddling doesn't seem to work - at least with my FTDI-USB - I need to have a prod at it with the scope to see if those pins are actually doing anything, but it's behaving as if there's no HW-Flow control.

d.

User avatar
hoglet
Posts: 7523
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by hoglet » Wed May 16, 2018 6:15 pm

danielj wrote:So, that HW-flow register twiddling doesn't seem to work - at least with my FTDI-USB - I need to have a prod at it with the scope to see if those pins are actually doing anything, but it's behaving as if there's no HW-Flow control.
Try with the fix I've just committed:
https://github.com/hoglet67/esp8266_mod ... 732099c027

Two changes:
1. Enable flow control after Serial.begin()
2. Use correct incantation for setting alternative pin functions

I've seen some evidence this works!

Dave

User avatar
danielj
Posts: 6597
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by danielj » Wed May 16, 2018 6:38 pm

Nearly there - I think that's the wrong pinmode for GPIO15 though, it's never giving the FTDI a signal that it's clear to send. Definitely responding to RTS. Is there a list of these anywhere?

User avatar
hoglet
Posts: 7523
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by hoglet » Wed May 16, 2018 8:40 pm

danielj wrote:Nearly there - I think that's the wrong pinmode for GPIO15 though, it's never giving the FTDI a signal that it's clear to send. Definitely responding to RTS. Is there a list of these anywhere?
I was going off the values here:
https://github.com/esp8266/Arduino/blob ... soc.h#L242

This is the direct I've not been able to test yet.

Are you saying that the RTS output of the esp8266 is stuck at "not ready to send"?

I've had this connected to the Beeb, but possibly I forgot to tell CommStar to use RTS/CTS flow control (if that's even possible...)

Dave

User avatar
danielj
Posts: 6597
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by danielj » Wed May 16, 2018 8:48 pm

Yes - so it sees the computer's RTS and sends the initial text, but it never asserts RTS itself, or at least not so far as the FTDI's concerned, so with hardware flow turned on the PC will never send anything to the ESP as it never thinks it's ready - if I turn off hardware flow it's fine so long as the FTDI continues to assert its own RTS. I've found the bitmasks, function_4 should be the right thing.

d.

Edit there's a stack of defines in here: https://github.com/esp8266/Arduino/blob ... 266_peri.h

:?

User avatar
hoglet
Posts: 7523
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by hoglet » Wed May 16, 2018 9:01 pm

This table also suggests GPIO15 / FUNCTION_4 is the correct thing for U0RTS.
https://www.esp8266.com/wiki/doku.php?i ... llocations

More head scratching needed....

It's possible to use flow control in one direction, but not the other. That might be a useful stop gap.

Dave

User avatar
danielj
Posts: 6597
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by danielj » Wed May 16, 2018 9:09 pm

It's most important for the beeb to stop it sending - I don't think the ESP is going to have too much trouble dealing with the data hurtling out of an 8bit machine through an ACIA :D - What I will do is try and see if it's just my FTDI dongle that's being grumpy or whether it's really not pushing out the right signal (I've not got a scope set up at the moment, so I'm sort of idling doing this with a laptop and a load of things hanging off USB cables) :)

d.

edit: I've just tried setting the pin as an output and holding it high/low, and it doesn't seem to register on my little ftdi board. I'm suspecting that's the issue now but will try and scope things to see...

User avatar
hoglet
Posts: 7523
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by hoglet » Thu May 17, 2018 11:21 am

Hi Daniel,

I've just checked again the level I'm seeing on RTS (IO15) on my board.

I'm seeing 0V on RTS out of the ESP board, which turns into +5V after going through the MAX232. This seems to be consistent with what the Beeb expects to see on CTS to allow it to send.

One thing to note, I am currently using a different board to you, an ESP 201:
IMG_1316.JPG
It's quite hard to actually generate any activity on RTS, because it seems the ESP firmware serial port is interrupt driven, so any time a character arrives in the hardware receive buffer is almost immediately removed. The only way I have been able to generate activity is by setting the flow control buffer threshold to zero, and then for each received character you get a brief 30-40us blip on RTS.

On you board, what's the quiescent level of RTS coming out of ESP board?

And you are using the following NodeMCU module pins:
- D7 (IO13) = CTS in to NodeMCU module
- D8 (IO15) = RTS out of NodeMCU module

Dave

User avatar
danielj
Posts: 6597
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by danielj » Thu May 17, 2018 1:31 pm

Perfect. Yup, 7 and 8 on the nodemcu. It'll be tomorrow when I manage to check what it's doing properly, but I suspect it's actually working! I'll tweak the hardware I've been putting together to have a jumper to select hardware flow, and also make sure 13/15 are used for the control lines to the rs232... makes like much easier.

Thanks for looking at this - if you want to make a pull request we can incorporate it into the stardot repo version?

d.

User avatar
hoglet
Posts: 7523
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by hoglet » Thu May 17, 2018 2:48 pm

danielj wrote: Thanks for looking at this - if you want to make a pull request we can incorporate it into the stardot repo version?
https://github.com/stardot/esp8266_modem/pull/3

User avatar
danielj
Posts: 6597
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by danielj » Thu May 17, 2018 8:19 pm

I've added schematics/PCB layout to the github repository now, so standalone direct-plug-in units can be built. Note, the PCB is as yet completely untested! It should, however, work with the firmware on the stardot repo.

d.

User avatar
danielj
Posts: 6597
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by danielj » Sat May 19, 2018 8:45 am

OK - confirm that hardware flow control is working with the NodeMCU on the beeb :)

Andy1979
Posts: 110
Joined: Mon Mar 27, 2017 9:04 pm
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by Andy1979 » Sat May 19, 2018 2:03 pm

OK, now have all the parts (I'm using a Wemos D1 mini board, having had good results with them before). Mixed results so far.

The ESP8266 modem is working. Tried it out with my Psion 3a first of all and was able to connect to bat.org.

Got Commstar onto an ADFS floppy via my Arc, and works with SRLOAD.

Annoyingly the RS232 port on my Master Compact (newly activated with chips from Retroclinic) doesn't seem to be able to send data. When I reset the ESP8266 Commstar receives the usual welcome text as per your guide, but I can't send any commands out. Tried hooking up my Psion to the Master Compact and I can send text from the Psion terminal to Commstar, but not the other way around.

Any ideas? I'm getting +8.5v and -8.9v at the test points on the motherboard. (should probably start a separate thread)

So close!!!

User avatar
danielj
Posts: 6597
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by danielj » Sat May 19, 2018 2:21 pm

No, you're probably nearly there. Which version of the firmware are you using? With or without the flow control? Depending on when you downloaded it, it may have had the flow control in by default, the current version has it disabled?

d.

Edit: More:

Check you've set both send and receive to 2400bps in the I settings menu in commstar. Have you got the service manual?

Andy1979
Posts: 110
Joined: Mon Mar 27, 2017 9:04 pm
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by Andy1979 » Sat May 19, 2018 2:30 pm

danielj wrote:No, you're probably nearly there. Which version of the firmware are you using? With or without the flow control? Depending on when you downloaded it, it may have had the flow control in by default, the current version has it disabled?

d.

Edit: More:

Check you've set both send and receive to 2400bps in the I settings menu in commstar. Have you got the service manual?
Both set to 2400. Have tried multiple Commstar versions, including Commstar II 2.40. Just realised I didn’t bridge the RTS/CTS pins. Could that be it?

User avatar
danielj
Posts: 6597
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by danielj » Sat May 19, 2018 2:43 pm

Yes, that'd potentially do it as the beeb won't think it can send.

d.

User avatar
danielj
Posts: 6597
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by danielj » Sat May 19, 2018 4:14 pm

Small update to the firmware - firstly sorting out the method used for ensuring background processes take place, secondly ensuring that when HW flow control is enabled, that it gets re-instigated post baud rate change. Tested CCl4 at 9600bps with hardware flow control enabled (max that you can do through commstar) and it was rock solid.

d.

Andy1979
Posts: 110
Joined: Mon Mar 27, 2017 9:04 pm
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by Andy1979 » Sat May 19, 2018 5:41 pm

danielj wrote:Yes, that'd potentially do it as the beeb won't think it can send.

d.
That's sorted it. Must have a crack at the version with flow control at some point. Am using one of the eBay double-sided MAX3232 boards with level shifters, which I think might even fit inside a 5 pin DIN connector.
IMG_5206.JPG
IMG_5221.JPG
IMG_5219.JPG
Thanks for making it all so easy to follow.

User avatar
danielj
Posts: 6597
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by danielj » Sat May 19, 2018 6:07 pm

Well done! - Did you manage to get commstar V2 to work with it and viewdata? I couldn't get to grips with it :?

d.

Andy1979
Posts: 110
Joined: Mon Mar 27, 2017 9:04 pm
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by Andy1979 » Sat May 19, 2018 6:46 pm

danielj wrote:Well done! - Did you manage to get commstar V2 to work with it and viewdata? I couldn't get to grips with it :?

d.
No, used Commstar 1.4 for Telstar. Commstar II seems to have viewdata and terminal as separate apps. Might give Communitel a try.

User avatar
danielj
Posts: 6597
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester
Contact:

Re: Cheap web-modem for the beeb/master (and arc if ya like!)

Post by danielj » Sun May 20, 2018 1:13 pm

So I've had a bit of a poke with Communitel - it's expecting a smart modem, which I'm assuming is one running the hayes command set... I *think* it's also expecting to talk to it at 1200 baud (no matter what) - there seem to be some *FX7,4s in the detection code.

Does anyone have any documentation from any of these old hayes compatible modems that were used with the beeb? I can then fiddle with the firmware to make sure it appears correct (to all intents and purposes) :)

d.

Edit: OK - so hayes modems expect commands to be issued at 1200bps, they change their speed once connected. This should be easy enough to implement, the bit where we struggle though is having differential upstream/downstream speeds for viewdata (i.e. 1200/75 or 75/1200).
I suspect it'll require some bodging of Communitel...

Post Reply