26Jun/180
I've got a brand new laptop at work and I didn't bother installing archaic versions of Visual Studio. Instead, VS Community 2017 was installed and, as part of it's due dilligence, it installs the prior VC Redistributibles to allow older applications to run. Think of these as dll-hell packages that provide the supporting libraries (glue) that VC++ compiled programs need to interface with the current Windows OS.
Anyway, when trying to install MySQL Workbench I was presented with the following pane:
Sure, I'll install VC 2015 redist, I'm obviously missing it! Oh wait.. I'm not..
0x80070666 - Another version of this product is already installed. Installation of this version cannot continue. To configure or remove the existing version of this product, use Add/Remove Programs on the Control Panel. Nice. Another version is actually NOT installed... another 'newer' version is, but it's an entire major version apart! Anyway, let's go see what we have installed...
VC Redist 2017, of course... thanks to VS 12017 itself. What happens if I remove it? Good question... regardless you can re-download the 2017 redistributibles here. I therefore removed the 2017 and then successfully installed 2015!
And the world was a happier place... then again, with MySQL Workbench installed I still couldn't see the database I was expecting... but that's another story.
China, 2018 – Shanghai and Guangzhou
China Southern had a great deal on return flights to Amsterdam, but the return leg included an inconveniently-timed 10-hour stopover in Guangzhou. Instead of this, I re-routed via Shanghai and decided that an overnight bullet train trip was in order. It's really the only thing that China has done over Japan, the building of high-speed beds! Well.. I lie. I wrote that last sentence prior to going and now that I'm back I'm seriously impressed with the culture, technology and overall livability of China. It was very different to when I was there 15 years ago!
Getting a Tourist Visa
So, Australia ain't on the cool-list. As an Australian, you'll have to fill out the application form and either post it to the consulate or deliver it in person to the application center. I chose the latter and, expecting that I had all the correct information, rocked up without an appointment on a Thursday lunch-time. After a 2.5hr wait, I was told that I needed print-outs of my hotel reservations. I'd totally neglected to read the requirements.
I returned to work and decided to choose some hotels later that night. Once done, I made the smart move and actually booked an appointment. DO THIS! DO NOT VISIT THE CENTER WITHOUT AN APPOINTMENT! With everything on me, I rocked up the following Monday and still had to wait for around 40 minutes. Once called up, all information was accepted and I was handed a receipt with an expected completion date. This was the following Thursday and, upon arrival, I waited in line to receive my passport with its pretty new Visa installed. AUD$109.95 later and I was set!
So, the basic idea is: Book EVERYTHING before you go and apply for a Chinese Visa. The form actually requires you to record where you are each night of your trip, so make sure you have the appropriate evidence per day.
This city is crazy... I stayed right in town at the Raddisson 'Tru Blu' and enjoyed it. The location was great for walking Nanjing Road to the Bund and also for getting a train to the computer area. Unfortunately the markets were really only full of new stuff. The area was pretty cool though with the overhead metro lines and grotty markets/streets. Check this link at Wikia for more information.
I had a friend help me work out cool places to check out trains. We were advised that the station platform at Lianhua Road Station on Subway Line 1.
The line parallels the actual main railway and there are two flat concrete platforms out from the station roof that you can use as viewpoints. Either gives a clear view in one direction and not the other. I was really happy though, there was a good mix of loco-hauled and high-speed trains through in the 30 minutes we hung around.
After this is was shopping, shopping and more shopping. Oh, and eating! Go to Da Dong for the most amazing Peking Duck.
The Overnight Bullet Train
After travelling on the Twilight Express, Kitaguni and Hokutosei... even the XPT in Australia and the Bangkok - Chiangmai Sleeper Train, it was time to ride the 'Deluxe Sleeper' from Shanghai to Guangzhou. This was going to be a 1400km coastal trip (not unlike the Twilight Express) with very convenient departure and arrival times.
This service only runs on Fridays, Saturdays, Sundays and Mondays, so make sure to plan your trip around the timetable. It seems that there's no demand mid-week and therefore does not run. Here's a recent Friday timetable.
The trains and stations were enormous and astonishing (that first photo above is from the mezzanine in the waiting area of Shanghai Hongqiao.) Just the sheer scale made them impressive. I must admit that the passengers were also very well behaved, when compared with normal public interactions. Everything felt a lot more like an airport than a train station. Most stations also had 16-or-more platforms with trains heading in numerous directions. Unfortunately, the waiting area was above the platforms and you only got to see the trains when you were called to board.
The consists were clean and tidy. It was funny looking at each of the models and thinking like I'd seen them before. Some were kawasaki-styled, others siemens-styled. Either way they all (well, except the very latest with its red livery) had the same white/black/blue colour schemes. Train after train departed and arrived at Shanghai and it was amazing to watch.
The cabins themselves were very similar to those of both Thailand and Japan. Everything was very shiny and new, but the tech wasn't overly 'premium'. The beds were already down and made, although it was already 2030.
Each bed had a TV, reading light, control panel and ample bedding. It was all looking very comfortable, except for the couch, which was a little hard and facing backwards... but that was luck of the draw as even-numbered cabins would've had the couch facing the other way. Anyway, it was dinner time...
The buffet car was next door and felt comfortable enough. It actually reminded me of my KTMB trip from Butterworth to KL. Nice and clean, boxes of stock piled high, very spartan outfit but functional and a simple menu. All items were 'bento' style and re-heated in the industrial-strength microwave. I chose the fish and suffered through a lot of tiny bones; still delicious!
Back to the cabin via the cute decor... there's a temperature control next to the door to make sure you have a comfortable sleep... although the upper berth may receive the majority of the aircon. Note that cabin number one (and the other end, I think 10? or 12?) are right next to the toilet. They're airplane toilets as well... so thanks to thin walls you can feel when people flush next to you.
The trip was fantastically timed and really easy. There was only one really major fault that I believe I may still be suffering from. The pressurisation of the carriages wasn't working. You could tell as soon as we were entering a tunnel as your ears would start to pop. And I don't mean just once... I mean about 5 times on entry and twice on exit of each tunnel. Worse when there was an opposing train! Even when lying down and sleeping I was awoken to aching eardrums once or twice.
We arrived into Guangzhou at 7am on a Tuesday and dumped my bags at the hotel. I ended up staying at the Royal Mediterranean Hotel in the Gang Ding area of Guangzhou... nice and close to all of the IT markets! It was too early to go shopping, so we ventured for the Canton Tower. This had an awesome observatory with a freakin' ferris wheel on the top!
Anyway... the days were mainly spent scouring through IT markets... but, of course, the effort was put in to ask the community where a good photography point would be. Turns out this one was a bit dicey. My friend was a local and declared that we could enter the area... but I was a little wary. We ended up taking Didi (Chinese Uber) and then riding the rental bikes to a rural area.
This area was known as the Xinshi Residential Area, or so I think? The maps are a little hard to work out. Either way, it was a side-road to a depot for track machines.
So.. yeah... after checking out the wagons, we *ahem* 'navigated' a fence and were presented with a fantastic line-side opportunity. Here's the northern view...
And then the southern view...
From here it was train-after-train-after-train. Seeing the signals helped a lot too. And this time there was freight! No high-speed though.
Lots of passenger consists... going to (or coming from) some very far reaching places!
Ahhhh... diesel freight... nothing better...
The passenger consists were actually seriously long. Turns out there was a bit of congestion too.
And then a final freight...
And finally... a puppy in a box...
...he wasn't a happy camper.
One final note.. China Southern is a fantastic airline. Three of the four legs of the trip to Amsterdam were on seemingly-brand-new Airbus A330s and the staff and food were fantastic. The leg from Amsterdam to Shanghai was actually operated by KLM, so that was also a nice surprise.
The final surprise was having the pilot draw a ring around the word 'Guangzhou' on the map as we departed for Melbourne. Things were amiss when we started heading west... I nearly thought I was in for another European holiday. We then veered south and I assumed we were to loop back and land in Guangzhou. But then as we swung around, out to the east was the most amazing storm-cell, smashing lighting in every direction. Fortunately this was well away from us and was exactly what the pilot was trying to avoid!
8Jun/180
Arduino – How to save power (and control 5v+)
For the first time ever, I get to play with Arduino at work! We're doing a little bit of work on tracking and the goal is to acquire as much data as possible and report it to a webserver. Therefore I've got sensors, GPS and GSM. As one can imagine, this consumes a lot of power, and as one can also imagine: the goal will be to obtain as long of battery life as possible.
Each of the modules requires either 3.3v or 5v and these are usually hardwired into the power supply. They also require anywhere from 50mA to 2A (GSM when sending data or searching for signals) and therefore can't be controlled directly from pins on the Arduino. Due to this I'll explain a proper mechanism to switch their power supplies on and off. Also, we'll then want to dig into power saving on the Arduino itself, so stick around.
Controlling modules from Arduino digital pins
Digital pins on the Arduino are only good for 30mA maximum. In fact, you shouldn't even be going anywhere near this. Hence, using one to provide +5v or GND to a module will cause that module's current needs to flow through the pin. For example, the GPS module I bought from Jaycar needs anywhere from 0-70mA. Although low, this is still too high for a digital pin.
The goal therefore is to use an electronic switch. You might be thinking 'relay', but you'll also need to note that they require current which can peak above the digital pin tolerance! You'll find that relay modules don't connect the relay actuator to the input.
The answer here is to use a transistor to allow current to flow to your modules. Depending on your current requirement, I can either recommend a 2N2222 (for anything up to 600mA) or a TIP31 (good for 3A.) I also want to switch my GSM module, and that needs 2A, so I bought a handful of TIP31s.
Using them is very straight-forward. Connect your VCCs up to whatever power source is needed and embed the transistors in the ground path. From here, switching the digital pin high will let current flow and complete the circuit for the module. Make sure you set your digital pinMode to OUTPUT.
Ideas for saving power via code
The basic idea is to put the Arduino to sleep whenever there's nothing to do. My device only needed to report every 15 minutes, so in the meantime I tried to make it snooze. It turns out that, based on internal timers and interrupts, you can only get a maximum of 8 seconds power down out-of-the-box. This wasn't quite the 15 minutes I was looking for, but numerous sources online said to just keep putting the unit to sleep for 8 seconds over-and-over.
There's some great reading here by Nick Gammon on power saving. Anything from lower frequencies to shutting down certain parts of your project. You'll also find a blog post here at the Arduino Playground describing other options. Just make sure you read that entire second article as other contributors have made corrections or other important points. Tis great to see the community involved.
...I'll come back to power saving once the project gets started up again. The proof-of-concept worked and now we need to convince the powers-that-be to let us continue.
Filed under: Arduino No Comments
Arduino – Don't buy the SIM900A for Australia!
tl;dr = This is a 2G-only device. There's only one network left, which shuts down on the 30th of June, 2018!
...but I needed a connection for work and I bought this unit from a seller on eBay without researching... so... compounding the error, I then also bought a SIM card for the network that'll still work: Vodafone. Thanks to Happymacer on Instructables who posted an article discussing how to use this device in Oz!
Note that I'd previously tried to use both Optus and Telstra SIM cards and got the following output when running the COPS command.
AT+COPS=?
+COPS: (3,"VODAFONE","voda AU","50503"),,(0-4),(0-2)
Yey! Vodafone! But I'm on Telstra/Optus? So I can see a Vodafone tower, but it's prepended with 3 which actually means I'm not allowed to use it. Sorta makes sense as Optus and Telstra switched off their 2G networks ages ago and Vodafone must have decided that lingering devices on other companies' plans aren't allowed to use their towers.
I bought a Vodafone SIM and ran the commands again...
Woweee! It's there. 2 means Roaming... which is a little weird, but it must be trying to hint to my device that 2G isn't the best method and that there should be a 3G tower around somewhere. Of course, even if there was, we couldn't connect to it. So I forced the connection with the following command...
AT+COPS=1,2,"50503"
+CREG: 2
Those CREGs afterwards were output because I had previously run AT+CREG=1. This command tells the device to report any changes to the carrier connection. What you can see is it connecting to the tower in roaming mode (aka 2) and then connecting correctly in local mode (aka 1.) We're on!
Testing SMS
If you wanna test an SMS, then you can do so pretty easily. Rig up a SoftwareSerial example in Arduino and make sure you can send commands to the SIM900A via the Serial Monitor. From here, you can use the following script to send an SMS.
AT+CMGF=1
AT+CMGS="+61xxxxxxxxx"
Note above ... you'll get the > prompt to enter the message. Once you're done, the unit requires a CTRL-Z control character to realise it's the end of the message. To do this, you'll need to open your favourite text editor, type ALT+026 (hold down ALT and type 0 then 2 then 6) and then copy the resulting character. It will be a black SUB if you use Notepad++. Now paste this into the text entry field in the Serial Monitor and hit enter.
Sending Data
From here, Jens Christoffersen at All About Circuits has helped us greatly with his article: Using a SIM900A to Send Sensor Data to a Website. Scroll down far enough and you'll find his code to send data to a server. He uses printf statements, as he's using a PIC and talking direct to the serial port... we'll have to use SoftwareSerial and print(ln).
AT+CGATT=1
AT+SAPBR=1,1
+SAPBR: 1,1,"100.84.75.204"
AT+HTTPINIT
AT+HTTPPARA="URL","http://www.website.com/index.php?data1=1&data2=4"
AT+HTTPPARA="CID",1
AT+HTTPACTION=0
+HTTPACTION: 0,200,0
AT+HTTPTERM
Above is an example chat with the unit to send data. Paste each AT line into the Serial Monitor first to make sure you get the expected responses. The URL above is rubbish, so put one in that'll work properly instead. The 200 in the HTTPACTION response is the happy HTTP code.
Thanks to hiring a car and touring Germany, I was able to visit some cool places like Miniatur Wunderland! Smashing the rental Jaguar XF on the autobahn was also fun... I was actually a little disappointed that the diesel didn't want to push much faster than 220km/h. The tour also took us on some back-roads as there were bridgeworks east of Bochum.
I can't even tell you where the above photo was taken as I was too busy negotiating bumper-to-bumper traffic on tiny country roads... but a freight passed a few seconds before and I was hoping to catch another.
The first night of the roadtrip was spent in Kassel. We hadn't booked in advance, so I chose the hotel closest to the station. This turned out to be a Best Western housed in a beautifully historical building. I assume it was actually once just the Hotel Kurfurst Wilhelm I?
It didn't have a railway view, but the station was right next door. We also didn't get much sunlight, but I managed to snap a military train the night we arrived!?
The next morning saw one freighter.. I got up and had breakfast as early as I could to then spend time down on the platform. The station is huge and has a tram interchange in the forecourt. The trams also take you right down into town. For some reason I didn't even take a photo of them!?
This was a very happy and random fluke. Turns out Leer (Ostfriesl) is on the mainline between a car plant and Emden Port and so there is a constant stream of traffic. Once again, we stayed in the hotel right next to the station, known as Hotel Frisia, which seemed to be very popular with the military.
The station itself probably has a lot of stories to tell. One of them might be that it's sick of looking at that weird yellow rocket on the round-a-bout out front.
So, where was I? Oh yes... the trains. As mentioned, there's a lot of freight traffic involving the transportation of new automobiles to the port in Emden. This comes from both directions, with the northbound trains turning on a siding just north of the station. You also get a lot of passenger trains. There's the Westfalen Bahn and the standard Deutsche Bahn. The former runs off to regional areas and the main company runs everything from long expresses to a Norddeich Mole which actually uses Leer as a turn-around station.
The Westfalen Bahn runs very regularly with 3-car EMUs. They're quite recent and in great condition. The colour scheme is also a nice change from the standard red of DB.
The Norddeich Mole runs from Norddeich via Emden through Leer to Hanover. It usually pulls into the third platform to keep the mainline free for all the other ICEs and freighters.
But then, sometimes another passenger train is on three and the Norddeich was on 2. Slightly confusing, but nobody seemed to miss their trains.
There's also an hourly ICE through to Stuttgart. But enough with the people carriers...
Turns out DB has their own Doctor Yellow and it, at this point in time, was diesel-powered and went for an excursion. It had actually been stored in a siding just north-west of the platforms.
From here, we'll talk freight. There were a lot of light engine moves and the drivers were in no mood to hang around. The engines happily went track-speed when they could. There were also a few loco shuffles.
Yeah... I know... you can hardly see there are two locos... you'll just have to trust me. Anyway, back to the actual freighters... from Platform one, if you look left (north), you'll see a branch that heads off right (east). the line heads off to Oldenburg and a lot of freight use Leer to get onto it.
For example, the above tanker consist had to snake its way across to the southbound rails, but proceeded south. The next snake didn't.
This train made it south of the station and into the yard. It then ran around and crossed back onto the northern line before continuing.
Finally, the fun part: the auto-carriers...
Both Volkswagen and Audi passed through the station... I still haven't quite worked out where their factories are. Numerous cargo companies were used to pull the services.
Meanwhile, the station has an amazing restaurant/cafe in it. Great pastries and breads... and coffee!
And here's a video of the view whilst I was sipping coffee.
And here's another freighter.
Oh! And a little diesel came through with parts of a wind turbine?
Finally... don't forget your snacks...
It's amazing seeing this much action in one place.
Filed under: INTL No Comments
Disused siding
Minoakasaka and Tomida - September 2010