28X2 to drive a Rev-Ed 4x20 OLED to tell the time with a DS3231

Rampz

Well-known member
I guessed the switches were there for test purposes, however the point I was trying to make is that if any of those buttons get pushed with the picaxe connected then 5v will get forced into a picaxe output pin.
Jack Yes like you say 5v would be forced into the picaxe pin. i can add diodes inline with the picaxe pin to prevent 5v entering the picaxe pins

I have just removed the loads that are switched and the code runs fine so seems to point to back emf issues from the electromagnet and possibly the motor actuator, not sure how to deal with this, maybe to opto isolate the inputs to the transistors to remove any path back, there can be a complete break including the GND terminal, because both loads are being reversed maybe only varisters are suitable, but won't work as well as a diode.

I haven't checked the voltage at the pendulum switch yet but i did take the 5v from the regulator to the +v of the pendulum switch, when i first built the board it was 12v and i got thinking thats not right so adapted it.

On the plans from Richard i did see that he had amended the plans to include a varistor on the elctromagnet, i guess he has similar issues with it causing an issue with the plc

Back to back 15V zeners at 1W looks to be the best way to sort emf issue or atleast i will give it a go

Edit

I have re-connected the electromagnet and code runs fine, tried it several times, all good, so it seems its the the actuator that is causing the problems, connected a varistor to the actuator terminals and so far its running correctly, so must be back emf problems and now is the time to find them
 
Last edited:

papaof2

Senior Member
Perhaps you could isolate which relay operation(s) cause a reset? Change the code to something like the below for each pulse group (first, second, etc):
sertxd("first pulse on",13,10)
pause 100
low Q1
pause 100
sertxd("Q1 operated",13,10)
low Q2
pause 100
sertxd("Q2 operated",13,10)
low Q3
pause 100
sertxd("Q3 operated",13,10)
sertxd("first pulse off",13,10)
 

Rampz

Well-known member
Perhaps you could isolate which relay operation(s) cause a reset?
Papaof2 Thank you for the reply, i removed the 2 loads that the 3 relays control, so just the relays connected and it ran fine, i re-connected the electromagnet and still ran fine, so re-connected the actuator and had problems, so seemed it was the actuator motor that caused so many problems, so connected a varistor across it and its run all night cycling through the code with everything working
 

Rampz

Well-known member
Hello again, possibly silly question
I'm working on a pcb for the project and running out of pins so looking to go to the 40X2 so i have pins spare.
Main question being on the OLED there are connections for RS and E can i use any outputs for these or does the pins i use have to have certain internal properties?
From a pcb point of view currently on the 28X2 the pins used are the Hserin and Hserout pins, i think it would be a good idea to leave these pins free incase i want to use the background data ability in the future, same on the 40X2
 

oracacle

Senior Member
I would double check the schematic for the 18m2 driver, but iirc they are busy Rob of the mill outputs.

Pretty sure E is enable so that should only need a gift low signal.
 

oracacle

Senior Member
They connect to c.6 and c.7 on the 18m2 which only have special functions for keyboards. So fun of three mill digital or should be fine
 

Rampz

Well-known member
I see on the AXE091 development board the resonator that is used is a 8Mhz, what does everybody use for a 40X2, does it matter what the resonator is within the 4Mhz to 16Mhz range? I thought we set the running frequency in the code, i see the picaxe store sells a 16mhz resonator along with other smaller sizes
 

oracacle

Senior Member
Iirc it doesn't need one unless you plan on over locking or the clock speeds to be very accurate. But 8 is the defualt
 

Rampz

Well-known member
The idea of moving over to the 40X2 is one thing, trying to buy one seems almost impossible to use on my AXE development board? Anyone know how currently has stock of them?

Maybe somebody has a spare one i can buy from them?
 
Last edited:

AllyCat

Senior Member
Hi,
does it matter what the resonator is within the 4Mhz to 16Mhz range?
Yes ! I'm not an X2 user but the SETFREQ Command Syntax seems fairly clear that unless you need to operate above 16 MHz and/or with a high accuracy clock, then you can use the Internal Resonator. However, IF you use the External Resonator then the Internal Clock Frequency is ALWAYS 4 times the Crystal Frequency, i.e. it is irrelevant (to the frequency generated) whether the SETFREQ actually specifies EM16, EM32, EM40 or EM64 :

28X2, 40X2internal k31, k250, k500, m1, m2, m4, m8, m16external em16, em32, em40, em64

"Note that the X2 parts have an internal x4 PLL inside the chip. This multiplies the external resonator speed by 4. Therefore the external resonator value to be used is 1/4 of the desired final speed (ie in mode em40 use an external 10MHz resonator, for em16 use a 4MHz resonator). "


Cheers, Alan.
 

Rampz

Well-known member
What I find misleading then is than the development board seems to have a 8mhz resonator fitted and by the terminal setup is running on the internal resonator at 8mhz, so it seems you can have an external resonator fitted and not actually use it, or my clock speed would be 32mhz which it isn't?
 

oracacle

Senior Member
It may well be left over from x1 and earlier generation chips that did require an external clock. Don't forget they are pin compatible chips.

Clock speed on the 40x2 is be defualt internal to 16mhz. To use the external crystal you need to an emXX command, mX will switch to internal resonator.

Trying to understand a commands and functions by the design of the board might not be the best way to do things, because it does not get close to telling the while story, specially when it comes to legacy hardware and it's design requirements. The 40x2 is a specially configured 28x2, ie with some extra pins. So what is true of the 28x2 is generally true due the 40x2.
 

Rampz

Well-known member
Ok thanks, so it looks like normal speed is 8Mhz and max speed without resonator is 16Mhz, and it will only use the external resonator if i use commands to tell it to, so my conclusion is to fit a 8Mhz resonator giving me access to a speed of 32Mhz by command should i need it later in my project.
 

Goeytex

Senior Member
You may be able to operate the 40X2 @ 32Mhz without a crystal/resonator.

Setting the PLL bit in the OSCTUNE register should multiply the default 8 MHz by 4, giving 32 MHz

For the 40X2 the code would be: PokeSFR $9B, %01000000

Whether or not this will work depends upon if Rev-ed has forbidden changing this register/bit.
 

hippy

Technical Support
Staff member
Whether or not this will work depends upon if Rev-ed has forbidden changing this register/bit
It's worth a try but I recall it was something we would have liked to provide but were not able to.

The main problem I believe is the internals are not quite as simple as the datasheet block diagrams would have one believe. I think it's a case that PLL cannot be applied to the internal oscillator when the external crystal oscillator is enabled as it needs to be to allow 'EMxx' selection and that's all buried in the small print.

The datasheet block diagram shows it as -

Code:
            _                     _
.-----.    | \        .-----.    | \
| EXT |--->| |   .--->| PLL |--->| |
`-----'    | |   |    `-----'    | |---> CLK
.-----.    | |   |               | |
| INT |--->| |---^-------------->| |
`-----'    |_/                   |_/
When in reality it is something like -
Code:
                0     1       _     _
         .------------------>| \   | \
.-----.  |    .----------.   | |-->| |
| EXT |--^-->| PLL / NOP |-->|_/   | |
`-----'      |___________|         | |---> CLK
.-----.      |           |    _    | |
| INT |--.-->| NOP / PLL |---| \   | |
`-----'  |   `-----------'   | |-->| |
         `-------------------|_/   |_/
Where the PLL silicon can be connected by a fuse configuration to either external or internal oscillator but not both.

One can see why they decided upon the simplified block diagram even though it's not completely accurate.
 

hippy

Technical Support
Staff member
What I find misleading then is than the development board seems to have a 8mhz resonator fitted and by the terminal setup is running on the internal resonator at 8mhz, so it seems you can have an external resonator fitted and not actually use it, or my clock speed would be 32mhz which it isn't?
The 28X2 and 40X2 default is internal 8MHz operation, with or without a crystal fitted, no matter what the crystal value is.

That can be doubled using SETFREQ M16 to get 16MHz operation, which is the maximum available internal frequency.

If a 4MHz crystal is fitted and you want to use that; you should specify SETFREQ EM16 and will get 16MHz operation
If an 8MHz crystal is fitted and you want to use that; you should specify SETFREQ EM32 and will get 32MHz operation
If a 16MHz crystal is fitted and you want to use that; you should specify SETFREQ EM64 and will get 64MHz operation
 

Rampz

Well-known member
Starting at building a PCB for the project, how best to turn the oled screen off when not needed? A n-type mosfet controlling negative to the screen maybe? Disable the E input? what's best for power saving, other than setup there will be nobody to see the screen 99% of its life
 

oracacle

Senior Member
Depending on what you have left pin wise on the PICAXE, you could just use a button. It seems power to the display and a signal to the PICAXE telling it to run the screen initialisation and what needs to be displayed. You could also use a toggle switch.

If you choose to remove power, you will need to run the initialisation sequence each time the screen is powered on iirc. It's been a while since I've investigated using a screen life that (and even it turned to not be necessary).
 

Rampz

Well-known member
Having been forced into the 40X2 I have spare pins, didn't really see any point having the screen showing when not required.
I do have a menu button already of which its first task can be to switch power on via an output and as you say rum the setup routine, good point that it needs doing I had overlooked that in my thoughts
 
Top